Steps to configure private registry for Docker Windows server 2016

Steps to configure private registry for Docker Windows server 2016

In this blog, we will show you the Steps to Configure private registry for docker Windows server 2016.

 

REQUIREMENTS

  • Windows VM with docker service
  • Linux VM (ubuntu or centos) with docker service

 

OVERVIEW

  • Docker registry is a core open-source project and it’s available for free in docker hub.
  • Docker registry will be installed locally so it will be secure and really very fast.
  • Currently, docker has not provided any registry container to run on windows platform.
  • So we need to use the Linux environment to configure the private registry to store our windows container images.

 

INSTALLING DOCKER ON WINDOWS

  • We have already installed docker service on windows server 2016.

Steps to configure private registry for Docker Windows server 2016

 

  • Please check the URL to install the docker on windows 2016.

https://www.assistanz.com/installing-docker-in-windows-2016/

 

PREPARING THE UBUNTU ENVIRONMENT

 

Note: We are using the ubuntu flavour OS for this demo

 

  • Login into ubuntu vm through putty.

Steps to configure private registry for Docker Windows server 2016

 

  • We have already enabled the root user to access the VM.

Steps to configure private registry for Docker Windows server 2016

 

  • Open the hostname file to add a hostname for this VM.

Steps to configure private registry for Docker Windows server 2016

 

  • Add a hostname for this VM along with IP. Save the changes and close the file.

Steps to configure private registry for Docker Windows server 2016

 

  • Update the available packages in the Ubuntu VM using apt-get update command.

Steps to configure private registry for Docker Windows server 2016

 

INSTALLING THE DOCKER ON UBUNTU

  • Use the below command to install the docker on ubuntu

apt-get install –y docker.io

Steps to configure private registry for Docker Windows server 2016

 

  • It will take few minutes to complete the operation.

Steps to configure private registry for Docker Windows server 2016

 

  • Check the docker service status using the below command.

service docker status

Steps to configure private registry for Docker Windows server 2016

 

  • To verify the docker version, type docker version command.

Steps to configure private registry for Docker Windows server 2016

 

CREATING DOCKER REGISTRY

  • You can find the docker official registry from the below URL.

https://hub.docker.com/_/registry/

Steps to configure private registry for Docker Windows server 2016

 

  • Use the docker pull command to pull the registry image from the docker hub.

docker pull registry

Steps to configure private registry for Docker Windows server 2016

 

  • You can verify the list of docker images using the below command.

docker images

Steps to configure private registry for Docker Windows server 2016

 

  • By default, docker registry will listen in port 5000. Launch the registry container using the docker run in detach mode along with port 5000 mapping.

docker run –name regdock -p 5000:5000 -d registry

Steps to configure private registry for Docker Windows server 2016

 

  • To verify the running container, execute the docker ps command.

Steps to configure private registry for Docker Windows server 2016

 

  • Now the container is listening in the port 5000. We can use the system name or IP to access this container from other machines.

 

VERIFY THE DOCKER REGISTRY CONTAINER

  • To get into the registry container, run the below command.

docker exec -it regdock sh

Steps to configure private registry for Docker Windows server 2016

 

  • The default location of registry config file inside the container is /etc/docker/registry/config.yml

Steps to configure private registry for Docker Windows server 2016

 

  • Open the config.yml file in VI editor. By default, it listens to port 5000 and our private images will be stored under /var/lib/registry directory.

Steps to configure private registry for Docker Windows server 2016

 

  • By default, registry container listens through https. To disable the HTTPS, Go-to /etc/docker/ directory on your Ubuntu machine.

Steps to configure private registry for Docker Windows server 2016

 

  • Create a new file name named daemon.json file and add the below entry.

{“insecure-registries”:[“privaterepo:5000”]}

Steps to configure private registry for Docker Windows server 2016

Steps to configure private registry for Docker Windows server 2016

 

Note: Here privaterepo is the machine host name. Modify it based on your machine name.

 

  • Save and close the file.

Steps to configure private registry for Docker Windows server 2016

 

PREPARE THE WINDOWS DOCKER MACHINE

  • Login into windows VM and Go-to C:\programdata\docker\config folder.

Steps to configure private registry for Docker Windows server 2016

 

  • Create a new filename daemon.json in that folder.

Steps to configure private registry for Docker Windows server 2016

 

  • Open the daemon.json file and add the below entry.

{“insecure-registries”:[“privaterepo:5000”]}

Steps to configure private registry for Docker Windows server 2016

 

  • Save and close the file.

 

  • Go-to C:\Windows\System32\drivers\etc folder.

Steps to configure private registry for Docker Windows server 2016

 

  • Open the hosts file in the notepad.

Steps to configure private registry for Docker Windows server 2016

 

  • Add your ubuntu machine name and its IP address.

Steps to configure private registry for Docker Windows server 2016

 

  • Save and close the hosts file. Verify the hostname through PING command.

Steps to configure private registry for Docker Windows server 2016

 

PREPARING THE IMAGES

  • From the windows machine,  type docker images to list the available images in the windows docker.

Steps to configure private registry for Docker Windows server 2016

 

  • The image name should be in the below format

private repo namespace:<portnumber>/imagename

Example: privaterepo:5000/mynanoserver

 

  • Rename the image name as shown as above. We are using nanoserver for this demo.

docker tag microsoft/nanoserver privaterepo:5000/mynanoserver

Steps to configure private registry for Docker Windows server 2016

 

  • Untag the old image name using the below command.

docker rmi microsoft/nanoserver:latest

Steps to configure private registry for Docker Windows server 2016

 

VERIFICATION

  • Use the below command to push docker images to docker registry.

docker push privaterepo:5000/mynanoserver

Steps to configure private registry for Docker Windows server 2016

 

  • We can use the below URL to view the list of images available in the private registry through a web browser.

http://privaterepo:5000/v2/_catalog

Steps to configure private registry for Docker Windows server 2016

 

Note: Privaterepo is the ubuntu machine name.

 

  • Login into registry container and go-to /var/lib/registry/docker/registry/v2/repositories directory and you will able to view the pushed images.

Steps to configure private registry for Docker Windows server 2016

 

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn about configuring the private repository for docker windows 2016.



Author: Loges
Logeswaran holds Microsoft certified engineer & solution architect certifications with over 11+ years of experience in the fields of hosting technologies and IMS/Cloud consulting. At AssistanZ, Logeswaran spearheads the strategic planning and execution of the company’s Microsoft based core technologies to Enterprise clients.

2 Comments

  • Sreejith

    Hi Loges,

    Quite informative with the screen shots. I actually reached your website while troubleshooting an issue with this.

    Well, I think we have an issue here with the setup. If you actually check the contents of your private repo, you will soon realize that the size is too small. As its mentioning skipping foreign layers, its not actually storing the nano server layer there….!

    Please have a look at this.

    Thanks & regards,
    Sreejith

  • Hi Sreejith,

    Thanks for the comment. We will check and update it.

    Regards,
    Loges

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.