Answers: <p>You need the <code>--with-registry-auth</code> flag, e.g.:</p>
  
  <pre><code>docker stack deploy -c myapp.yml --with-registry-auth myapp
  </code></pre>
  
  <p>From the <code>docker stack deploy --help</code> output:</p>
  
  <pre><code>--with-registry-auth     Send registry authentication details to Swarm agents 
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-07-20T06:06:28.827Z
Answers: In case somebody wondered, the last arg is the swarm name (and not some authentication token or something); so more generically written the deployment takes form `docker stack deploy -c docker-compose.yml --with-registry-auth my_swarm_name`
Answers: P Marecki
Answers: CC BY-SA 4.0
Answers: 2021-07-20T11:03:43.113Z
Answers: @PMarecki it's the stack name, same as you'd include in a deploy command without the flag. The `--with-registry-auth` flag takes no options, it passes you local credentials from previous login commands to the nodes running the containers.
Answers: BMitch
Answers: CC BY-SA 4.0
Answers: 2020-04-06T18:01:05.363Z
Answers: 2020-04-06T18:01:05.363Z
Answers: BMitch
Answers: <p>first you need to do docker login to repo then you do stack deploy with --with-registry-auth flag.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-10-13T09:37:41.523Z
Answers: 2020-10-13T09:37:41.523Z
Answers: KiranM
Body: <p>I am trying to deploy a docker swarm using Digital Ocean's docker-machine driver. </p>
  
  <p>This is currently a single node that contains several public DockerHub images, and one private. </p>
  
  <p>I am having difficulties in configuring it to accept the private image properly.</p>
  
  <p>I have SSHed into the node, and used <code>docker login</code>. After that, I was able to properly <code>docker pull</code> the private image. </p>
  
  <p>But, when trying to run <code>docker stack deploy -c myapp.yml myapp</code>, I am getting this warning:</p>
  
  <pre><code>image me/myapp:latest could not be accessed on a registry to record
  its digest. Each node will access me/myapp:latest independently,
  possibly leading to different nodes running different versions of the image.
  </code></pre>
  
  <p>What do I need to do to properly login to a private registry in docker swarm mode?</p>
  
Tags: <docker><docker-swarm><docker-registry><docker-machine>
Title: Access private DockerHub repo in Docker Swarm
UserDisplayName: DannyB
ThreadText: # Access private DockerHub repo in Docker Swarm
  
  (Asked by: username_0 on 2019-10-15)
  
  I am trying to deploy a docker swarm using Digital Ocean's docker-machine driver.
  
  This is currently a single node that contains several public DockerHub images, and one private.
  
  I am having difficulties in configuring it to accept the private image properly.
  
  I have SSHed into the node, and used `docker login`. After that, I was able to properly `docker pull` the private image.
  
  But, when trying to run `docker stack deploy -c myapp.yml myapp`, I am getting this warning:
  
  ```
  image me/myapp:latest could not be accessed on a registry to record
  its digest. Each node will access me/myapp:latest independently,
  possibly leading to different nodes running different versions of the image.
  
  ```
  
  What do I need to do to properly login to a private registry in docker swarm mode?
  
  **Tags:** docker, docker-swarm, docker-registry, docker-machine
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-04-06. Score: 3
  
  You need the `--with-registry-auth` flag, e.g.:
  
  ```
  docker stack deploy -c myapp.yml --with-registry-auth myapp
  
  ```
  
  From the `docker stack deploy --help` output:
  
  ```
  --with-registry-auth     Send registry authentication details to Swarm agents 
  
  ```
  
  > **Comments:**
  > **username_2**: In case somebody wondered, the last arg is the swarm name (and not some authentication token or something); so more generically written the deployment takes form `docker stack deploy -c docker-compose.yml --with-registry-auth my_swarm_name`  
  > **username_1**: @username_2 it's the stack name, same as you'd include in a deploy command without the flag. The `--with-registry-auth` flag takes no options, it passes you local credentials from previous login commands to the nodes running the containers.  
  
  ---
  
  ### Answer by username_3 on 2020-10-13. Score: 0
  
  first you need to do docker login to repo then you do stack deploy with --with-registry-auth flag.
  
  
  ---
  
  