Private Docker Registry with Swarm
- Works the same way as localhost
- Because of Routing Mesh, all nodes can see 127.0.0.1:5000
- Remember to decide how to store images (volume driver)
- NOTE: All nodes must be able to access the images
- ProTip: Use a hosted SaaS registry if possible
How to do it
~> docker service create --name registry -p 5000:5000 registry
ocs4bnqw1crnbivjh74gy9lv8
~> docker service ps registry
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
3bk9yp618nnb registry.1 registry:latest manager1 Running Running 10 seconds ago
- Re-tag an existing image and push it to your new registry
docker tag hello-world 127.0.0.1:5000/hello-world
docker tag nginx 127.0.0.1:5000/nginx
docker push 127.0.0.1:5000/hello-world
docker push 127.0.0.1:5000/nginx
- Remove that image from local cache and pull it from new registry
docker image rm hello-world
docker image rm nginx
docker image rm 127.0.0.1:5000/hello-world
docker image rm 127.0.0.1:5000/nginx
docker pull 127.0.0.1:5000/hello-world
docker pull 127.0.0.1:5000/nginx
- We can visit catalog on
hostname:5000/v2/_catalog
{
"repositories": [
"hello-world",
"nginx"
]
}