Running a registry container

Running your own registry lets you share images between team members and store the output of all your application builds using the fast local network instead of an internet connection. You would typically run the registry container on a server that can be widely accessed in a configuration like this:

The registry is running in a container (1) on a server (2). The client machines (3) are connected to the server so that they can use the registry on the local network to push and pull private images.

To make the registry container accessible, you need to publish port 5000 from the container to port 5000 on the host. Registry users can access the container using the host server's IP address or hostname, and that will be the registry domain you use in image names. You'll also want to mount a volume from the host to store the image data in a known location. When you replace the container with a new version, it will still be available using the host's domain name, and it will still have all the image layers stored by the previous container.

On my host server I have a RAID array configured as disk E:, which I use for my registry data so that I can run my registry container mounting that volume for the data path:

mkdir E:
egistry-data
docker container run -d -p 5000:5000 -v E: egistry-data:C:data dockeronwindows/ch04-registry:2e

In my network I'll be running the container on a physical machine with the IP address 192.168.2.146. I could use 192.168.2.146:5000 as the registry domain to tag images, but that isn't very flexible. It's better to use the domain name of the host so that I can point that to a different physical server if I need to without having to re-tag all my images.

For the hostname you can use your network's Domain Name System (DNS) service, or a Canonical Name (CNAME) if you're running a public server. Alternatively you could add an entry to the hosts file on the client machines and use a custom domain name. This is the PowerShell command I use to add the hostname entry for registry.local, pointing to my Docker server:

Add-Content -Path 'C:WindowsSystem32driversetchosts' -Value "`r`n192.168.2.146 registry.local"

Now my server is running a registry server in a container with reliable storage, and my client is set up to access the registry host using a friendly domain name. I can start pushing and pulling private images from my own registry, which is only available to users on my network.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.98.207