Docker private registry

Docker even has a public registry called Docker Hub to store Docker images. While Docker lets you upload your Docker creations to their Docker Hub for free, anything you upload is also public. This might not be the best option when you work on your projects or inside your organization.

So I wanted to spin up my own private docker registry based on … docker. Actually docker-compose as I need to components for my repo: the docker server itself and the nginx server acting as a proxy to handle authentication and ssl.

Below the docker-compose.yml file I’m using to spin up the environment:

On my host I created two directories to handle data images and nginx configuration.

In nginx directory I added the configuration file nginx.conf together with the ssl certificate.

The registry.password file is used by nginx to keep users and passwords for our registry.

Initially created with

you can strip -c and add additional users.

You can spin up the docker registry with:

If everything is ok, you can check if platform is up:

If you want to start docker-registry as a service you need to create the Upstart script:

Let’s test our new Upstart script by running:

Feel free to check the log files:

Your private repository is accessible via https://registry.iulitab.co.uk:5443/v2/

Using our private docker registry:

You can login to your registry with:

From your client machine, create a small empty image to push to our new registry. We will create a simple image based on the ubuntu image from Docker Hub

Inside the container create a dummy directory (eg. my_application) and commit the change:

then tag the image:

Note that you are using the local name of the image first, then the tag you want to add to it. The tag does not use https://, just the domain, port, and image name.

Now we can push that image to our registry. This time we’re using the tag name only:

Similar you can pull images from your private registry:

or

Happy Dockering!