Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploy stack to remote swarm

Good morning,
I'm approaching docker swarm now and I'm having trouble finding some information. My goal is to create a gitlab or travis deployment to my swarm cluster, I created my manager node with the docker swarm init command and created a docker registry as a service; as indicated in the official documentation.

Here is my very simple dockerfile

FROM node:9.5.0

ADD . .

RUN yarn install

CMD [ "yarn", "start" ]

and here my compose

version: '3'

services:
  healthcheck:
    image: <registry_url>:<registry_port>/healthcheck
    build: .

Launching the command

docker-compose push

from another not-swarm server in the work fine and my image is correctly uploaded to the registry.

So now I think I have to deploy my stack with something like this (remember that I am running the following command from another server)

export DOCKER_HOST=tcp://<my_manager_url>:<my_manager_port>
docker stack deploy --compose-file docker-compose.yml healthcheck

but the swarm server reject me and i don't know witch is the right port.

I think it must be configured in some way but I have not found anything about it.

I'm on the right way? Could you suggest me the documentation I did not find?

Thanks in advance

like image 424
Federico Bevione Avatar asked Jan 28 '23 16:01

Federico Bevione


2 Answers

You are trying to reach the remote Docker Daemon to push your compose.yml. But the problem is by default Docker Daemon is only bound to unix socket.

To do so, on your remote server, you will have to alter /usr/lib/systemd/system/docker.service file and change ExecStart to...

ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

then,

systemctl daemon-reload

and restart

service docker restart

I wouldn't recommend you this setup without securing the Daemon with TLS. If you don't use TLS anyone can reach out to your server and deploy containers.

Hope it helps!

like image 150
Ahab Avatar answered Jan 31 '23 09:01

Ahab


Yea, like @Ahab says at end, you don't want to enable TCP on the docker service unless it's secured with TLS. Two options:

Follow the documentation for enabling TLS on the remote daemon.

Use Docker Cloud's easy "bring your own swarm" feature to manage TLS for you.

like image 41
Bret Fisher Avatar answered Jan 31 '23 07:01

Bret Fisher