Reputation: 139
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
Upvotes: 6
Views: 7121
Reputation: 1
The following command will deploy a compose file as a stack to a remote host. The remote host must be a known host before running the command.
docker -H ssh://<remote-host-credentials> stack deploy -c <path-to-compose-file> <stack-name>
Upvotes: 0
Reputation: 8596
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.
Upvotes: 2
Reputation: 780
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!
Upvotes: 6