Search code examples
dockerdocker-registry

Docker Swarm and self-signed Docker Registry


Does Docker Swarm support usage of Docker Registry with self-signed certificate?

I've created my cluster based on step from official Docker documentation, it uses swarm master/nodes running inside containers.

It works well, but as soon as I try to login to my Docker Registry I'm getting error message:

$ docker -H :4000 login https://...:443
...
Error response from daemon: Get https://.../v1/users/: x509: certificate signed by unknown authority

Is there an additional option which needs to be set, like --insecure-registry? Or do I need to somehow update Docker Swarm container?


Solution

  • You need to add your self signed cert or personal CA to the list of trusted certificates on the host. For some reason, docker doesn't use the certificates on the daemon for this authentication. Here are the commands for a debian host:

    sudo mkdir -p /usr/local/share/ca-certificates
    sudo cp ca.pem /usr/local/share/ca-certificates/ca-local.crt
    sudo update-ca-certificates
    sudo systemctl restart docker
    

    The docker restart at the end is required for the daemon to reload the OS certificates.

    As luka5z saw in the latest documentation, you can also add the certs directly to each docker engine by copying the cert to /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt. This avoids trusting the self signed CA on the entire OS.