2

I have a private docker registry, and when I pull images from it everything is OK But when I want to start a docker swarm service:

docker service create --name myredis --network mynetwork --replicas 1 -p 6379:6379 myregistry:8082/redis

, it shows me next error

unable to pin image myregistry:8082/redis to digest: Head http://myregistry:8082/v2/redis/manifests/latest: no basic auth credentials

How can I use my local registry while creating docker swarm services?

Nurzhan Aitbayev
  • 797
  • 1
  • 10
  • 23

1 Answers1

5

Add --with-registry-auth to your docker stack deploy or docker service create commands. In a swarm, your host is logged in (so you can pull and run) but your workers are not. This passes the login token from your local client to the swarm nodes where the service is deployed.

hammady
  • 969
  • 1
  • 13
  • 22
Siyu
  • 11,187
  • 4
  • 43
  • 55
  • Make sure that you have done a `docker login` to your private registry from the nodes. After that redeploy your stack with `--with-registry-auth`. Saved credentials when you performed `docker login` will be used for pulling images from docker registry – donnie May 22 '19 at 13:57
  • 2
    @donnie no that's not required, typically docker nodes are volatile in a dynamic environment. The above answer is just enough as it makes sure the credentials are transferred from the docker client machine (the one that does docker login during deployment) to current and *future* worker nodes. – hammady Apr 18 '21 at 18:15