How should a registry be run in a docker swarm?

474 Views Asked by At

In docker swarm mode with 2 nodes, if I do:

node1master# docker service create --name registry --publish 5000:5000 registry:2

then I cannot access the registry by doing:

node1master# telnet localhost 5000
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

because the registry is now running on node2worker:

node2worker# telnet localhost 5000
Trying ::1...
Connected to localhost.
Escape character is '^]'.

(of course it could be scheduled on node1master, but in this case it isn't)

What I don't understand is why the registry is not connected to the ingress network.

What I think makes sense is a registry that is connected to the ingress network as long as docker itself routes requests for localhost:5000 through the ingress network.

How should the registry be run so that it either is available as localhost:5000 on all nodes (using the ingress network I guess), or as some fixed DNS name that works for the docker daemon.

0

There are 0 best solutions below