# Deploying Docker Swarm

**URL:** <https://discuss.circleci.com/t/deploying-docker-swarm/20959>\
**Category:** Deployments\
**Tags:** 2.0, circle-yml, docker, deployment\
**Created:** [March 22, 2018, 9:31pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959 "2018-03-22T21:31:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![4doge](https://avatars.discourse-cdn.com/v4/letter/4/278dde/32.png) [@4doge](https://discuss.circleci.com/u/4doge)\
**Post date:** [March 22, 2018, 9:31pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/1 "2018-03-22T21:31:49Z")

</div>

Hello there!

I’m using the CircleCI for a long time for building Docker Images and deploying to Docker Hub.  
Since Docker Cloud from 21 of May will work only in a Docker Swarm mode I hope that i can deploy to Docker Swarm from CircleCI.  
I rewrite my configuration for a simple project.  
The current main step in my configuration is next:

```
CONNECT_RESULT=$(docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -e DOCKER_HOST dockercloud/client -u $DOCKER_CLOUD_USERNAME -p $DOCKER_CLOUD_PASSWORD **swarmhere** )
echo $CONNECT_RESULT
HOST_REGEX="DOCKER_HOST=?(.+)"
[[$CONNECT_RESULT =~ $HOST_REGEX]] && DOCKER_IP=${BASH_REMATCH[1]}
echo $DOCKER_IP
export DOCKER_HOST=$DOCKER_IP
docker stack deploy --compose-file docker-stack.yml example --with-registry-auth

```

And after that i getting error:

> Cannot connect to the Docker daemon at tcp://xx.xx.xx.xx:32768. Is the docker daemon running?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 22, 2018, 11:04pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/2 "2018-03-22T23:04:02Z")

</div>

Is that run in the context of your Circle container? If so, readers would probably need to see your Circle 2.0 config, and in particular what base image you’re running on.

I wonder, would the configuration you have shown already be best rendered as code? You’ve put it in a quote block, and I don’t know if pre-formatting it would make it more readable (this is certainly the case for YAML, of course). If you have not seen it yet, the code button in the toolbar looks like this: `</>`.

---

<div class="post-metadata">

**Author:** ![4doge](https://avatars.discourse-cdn.com/v4/letter/4/278dde/32.png) [@4doge](https://discuss.circleci.com/u/4doge)\
**Post date:** [March 23, 2018, 4:32am UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/3 "2018-03-23T04:32:15Z")

</div>

> Is that run in the context of your Circle container?

I think yes.  
Also I edit the topic and now it looks better with code formatting. Thanks.  
Any thoughts?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 23, 2018, 10:45am UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/4 "2018-03-23T10:45:38Z")

</div>

I’m not familiar with Swarm, but what CircleCI base image are you using? Are you using a Docker image such as `docker:17.05.0-ce-git`?

---

<div class="post-metadata">

**Author:** ![4doge](https://avatars.discourse-cdn.com/v4/letter/4/278dde/32.png) [@4doge](https://discuss.circleci.com/u/4doge)\
**Post date:** [March 23, 2018, 11:03am UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/5 "2018-03-23T11:03:26Z")

</div>

```
docker:
      - image: circleci/node:latest
```

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 23, 2018, 11:03am UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/6 "2018-03-23T11:03:55Z")

</div>

Righto. Does that have Docker installed in it? 😸

If not, I guess that would the cause…

---

<div class="post-metadata">

**Author:** ![4doge](https://avatars.discourse-cdn.com/v4/letter/4/278dde/32.png) [@4doge](https://discuss.circleci.com/u/4doge)\
**Post date:** [March 23, 2018, 11:06am UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/7 "2018-03-23T11:06:03Z")

</div>

I think yes, because I’m also have the:  
`- setup_remote_docker`  
And I’m able to run docker commands such as run/build/push  
I’m stuck with the same problem as described here - [https://forums.docker.com/t/deploying-in-swarm-mode-ci-cd/30008/16](https://forums.docker.com/t/deploying-in-swarm-mode-ci-cd/30008/16)

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 23, 2018, 12:40pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/8 "2018-03-23T12:40:48Z")

</div>

Hmm, OK. Which command is producing the Docker error? It looks like you’re sharing the Docker volume into a container, so there may be permissions problems. Check that everywhere you are issuing a `docker` command, your user is a member of the `docker` user group (even in containers).

Do you get the expected results for `$CONNECT_RESULT` and `$DOCKER_IP`?

---

<div class="post-metadata">

**Author:** ![4doge](https://avatars.discourse-cdn.com/v4/letter/4/278dde/32.png) [@4doge](https://discuss.circleci.com/u/4doge)\
**Post date:** [March 23, 2018, 12:46pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/9 "2018-03-23T12:46:11Z")

</div>

Yes, the **$CONNECT\_RESULT** and **$DOCKER\_ID** is fine.  
This error is when i’m run  
`docker stack deploy`  
If you check this link [https://forums.docker.com/t/deploying-in-swarm-mode-ci-cd/30008/7](https://forums.docker.com/t/deploying-in-swarm-mode-ci-cd/30008/7)  
you will get further into this issue

> Since CircleCI uses a remote docker install, you can’t just set DOCKER\_HOST locally since it will just override the value for the remote host. So I create a container on the remote instance to act as a proxy and set DOCKER\_HOST inside of it and then run subsequent commands in there.  
> Note the use of --with-registry-auth to ensure that the credentials are used on all of the nodes in the swarm.

And I don’t know how to solve that.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 21, 2018, 12:46pm UTC](https://discuss.circleci.com/t/deploying-docker-swarm/20959/10 "2018-06-21T12:46:13Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
