I've got a docker-compose.yml file and if I run docker swarm init I can:
$ docker stack deploy --compose-file=docker-compose.yml example
And it all works fine.
I gather though that I can't use docker stack deploy
to deploy to a swarm my host isn't part of.
So I started a few Virtualbox instances:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
manager - virtualbox Running tcp://192.168.99.102:2376 v17.05.0-ce
worker1 - virtualbox Running tcp://192.168.99.100:2376 v17.05.0-ce
worker2 - virtualbox Running tcp://192.168.99.101:2376 v17.05.0-ce
I've joined the workers to the manager.
$ docker-machine ssh worker1 "docker swarm join --token=${worker_token} --listen-addr $(docker-machine ip worker1) --advertise-addr $(docker-machine ip worker1) $(docker-machine ip manager)"
$ docker-machine ssh worker2 "docker swarm join --token=${worker_token} --listen-addr $(docker-machine ip worker2) --advertise-addr $(docker-machine ip worker2) $(docker-machine ip manager)"
I wondered if my host could join the swarm, run the stack deploy and leave it?
Attempting to join it fails.
Error response from daemon: can't initialize raft node: rpc error: code = 2 desc = could not connect to prospective new cluster member using its advertised address: rpc error: code = 4 desc = context deadline exceeded
So my question is, how can I deploy my docker-compose stack to a swarm I'm not a part of? Is copying the file up and running the stack deploy there really the way to do it?