Docker Registry on local network.

So, we all have used Docker Hub and it’s private repositories, but sometimes, if we want to do some testing on the local network and want to save some bandwidth, we could set up our own Docker Registry. If you want to read that documentation that’s fine. But this is to just get you running.

The machine on which you want to configure the registry(Let’s call it the server) must have a static IP. Add an entry to your /etc/hosts file (Linux or MAC). Then follow these steps (Run these on the server only.)

mkdir -p certs && openssl req \ -newkey rsa:4096 -nodes -sha256 -keyout certs/docker.key \ -x509 -days 365 -out certs/docker.crt

Then, run this command. (Obviously you have docker installed and configured for your user! You’re not that dumb. 😉 )

docker run -d -p 5000:5000 --restart=always --name registry \
-v `pwd`/data:/var/lib/registry \
-v `pwd`/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/docker.key \

You are almost done! Just two more steps left to configure your docker engine to talk to this registry. (These must be done on your local machines)

  1. Copy the docker.crt file to /etc/docker/certs.d/docker.local:5000/ca.crt
  2. Restart Docker Engine. (systemctl restart docker)



Leave a Reply

Your email address will not be published. Required fields are marked *