I'm trying to run the registry container (registry:2.1) on my domain but I'm getting the following error:
10.100.1.1:443: bind: cannot assign requested address
In my config file, I have the following http block:
http:
addr: example.net:443
net: tcp
tls:
certificate: /etc/docker/registry/ssl/example.net.cert
key: /etc/docker/registry/ssl/example.net.key
Output from host example.net
example.net has address 10.100.1.1
I've tried directly setting the IP in the addr param, setting it to the external IP of the instance and with different ports but still the same error. I've looked at the configuration reference documentation which says:
The address for which the server should accept connections. The form depends on a network type (see net option): HOST:PORT for tcp and FILE for a unix socket.
Am I doing this incorrectly?
The host network interface (and therefore its IP address) are not available to bind within a Docker container. Leave the host as localhost and then bind the configured port to the IP and port on the host.
Please familiarise yourself with basic Docker functionality, especially https://docs.docker.com/articles/networking/#binding-ports
The answer in this case (when you change example.net to localhost in your config) is
-p 10.100.1.1:443:443
Thanks for the quick response! I thought this might be the issue but was confused by the documentation as it states:
The address for which the server should accept connections. The form depends on a network type (see net option): HOST:PORT for tcp and FILE for a unix socket.
I took this to mean that it would only accept connections from that domain/IP which I know see is incorrect, it's just a bind address.
I managed to get it working by not specifying a host, just a port
http:
addr: :443
Yeah, the instructions work if you run registry outside of a container, directly on the host. Everything becomes muddled when including Docker :)
Exactly =] I found it a bit strange that all the config reference is mainly for running it outside of docker but the deployment part is entirely for docker =p
Most helpful comment
The host network interface (and therefore its IP address) are not available to bind within a Docker container. Leave the host as localhost and then bind the configured port to the IP and port on the host.
Please familiarise yourself with basic Docker functionality, especially https://docs.docker.com/articles/networking/#binding-ports
The answer in this case (when you change example.net to localhost in your config) is
-p 10.100.1.1:443:443