Deploying Docker Swarm

deployment
docker
circle.yml
2.0

#1

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?


#2

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: </>.


#3

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?


#4

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?


#5
docker:
      - image: circleci/node:latest

#6

Righto. Does that have Docker installed in it? :smile_cat:

If not, I guess that would the cause…


#7

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


#8

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?


#9

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
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.


#10

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