Stobor
Stobor

Reputation: 65

docker-compose swarm without docker-machine

After looking through docker official swarm explanations, github issues and stackoverflow answers im still at a loss on why i am having the problem that i have.

Issue at hand: docker-compose up starts services not in the swarm even though swarm is active and has 2 nodes.

Im using 1.12.1 docker version.

  1. Looking at swarm tutorial i was able to start and scale my swarm using docker service create without any issues.

  2. running docker-compose up with version 2 docker-compose.yml results in services starting outside of swarm, i can see them through docker ps but not docker service ls

I can see that docker-machine as the tool that solves this problems, but then again it needs virtual box to be installed.

so my questions would be

  1. Can i use docker-compose with docker-swarm (NOT docker-engine) without docker-machine and without experimental build bundle functionality?

  2. If docker service create can start a service on any nodes is it an indication that network configuration of the swarm is correct ?

  3. What is the advantages/disadvantages of docker-machine versus experimental build functionality

Upvotes: 1

Views: 1205

Answers (2)

Elton Stoneman
Elton Stoneman

Reputation: 19194

1) No. Docker Compose isn't integrated with the new Swarm Mode yet. Issue 3656 in GitHub is tracking that. If you start containers on a swarm with Docker Compose at the moment, it uses docker run to start containers, which is why you see them all on one node.

2) Yes. Actually you can use docker node ls on the manager to confirm all the nodes are up and active, and docker node inspect to check a particular node, you don't need to create a service to validate the swarm.

3) Docker Machine is also behind the 1.12 release, so if you start a swarm with Docker Machine it will be the 'old' type of swarm. The old Docker Swarm product needed a whole lot of extra setup for a key-value store, TLS etc. which Swarm Mode does for free.

Upvotes: 2

Bernard
Bernard

Reputation: 17311

1) You can't start services using docker-compose on the new Docker "Swarm Mode". There's a feature to convert a docker-compose file to the new dab format which is understood by the new swarm mode but that's incomplete and experimental at this point. You basically need to use bash scripts to start services at the moment.

2) The nodes in a swarm (swarm mode) interact using their own overlay network. It's the one named ingress when you do docker network ls. You need to setup your own overlay network to run services in. eg:

docker network create -d overlay mynet
docker service create --name serv1 --network mynet nginx

3) I'm not sure what feature you mean by "experimental build'. docker-machine is just a way to create hosts (the nodes). It facilitates the setting up of the docker daemon on each host, the certificates and allows some basic maintenance (renewing the certs, stopping/starting a host if you're the one who created it). It doesn't create services, volumes, networks or manages them. That's the job of the docker api.

Upvotes: 1

Related Questions