Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using docker-compose with docker-engine's swarm mode #3656

Closed
selvik opened this issue Jun 28, 2016 · 26 comments
Closed

Using docker-compose with docker-engine's swarm mode #3656

selvik opened this issue Jun 28, 2016 · 26 comments

Comments

@selvik
Copy link

@selvik selvik commented Jun 28, 2016

Hi,

Could someone point me to instructions on using docker-compose to schedule services on the new docker-engine swarm mode cluster?

When I try to do a:

  1. eval $(docker-machine env [swarm-master-hostname])
  2. docker-compose up
  3. All the services defined in my docker-compose.yaml file get started up as containers on the single host.

How can I get the services defined in my docker-compose file started up as "services" in swarm mode?

Thanks!
-Selvi

@JeremyRubin

This comment has been minimized.

Copy link

@JeremyRubin JeremyRubin commented Jun 29, 2016

From what I can tell, docker-compose is not yet compatible with the new swarm-mode. It's unclear when these integrations will be available.

@johnharris85

This comment has been minimized.

Copy link
Contributor

@johnharris85 johnharris85 commented Jul 5, 2016

Swarm mode is not supported by compose yet. Compose basically does a run on the containers in your compose file. In swarm mode run only schedules containers on the daemon to which your client is connected.

You can use the new bundle feature (only in compose > 1.8) to get what you want though. Run docker-compose bundle in your compose folder and it will generate a something.dsb file. Then you can run docker deploy something (no extension). This will schedule your containers across the swarm.

@selvik

This comment has been minimized.

Copy link
Author

@selvik selvik commented Jul 6, 2016

Thanks @johnharris85. The new workflow you've suggested works for me. So my follow up question is: Is this the new intended workflow henceforth or will docker-compose be updated to run services directly?

@johnharris85

This comment has been minimized.

Copy link
Contributor

@johnharris85 johnharris85 commented Jul 6, 2016

@selvik I would expect that compose would get some native integration with swarm mode, but don't have any specific details or timeframes.

@freeseacher

This comment has been minimized.

Copy link

@freeseacher freeseacher commented Jul 22, 2016

so. just to sum up.

it means docker-compose - looks useless for more than one node :( again.
and talks about backward compatibility from https://www.youtube.com/watch?v=F7hoq0KwHD4 ... fake.

@aanand

This comment has been minimized.

Copy link
Contributor

@aanand aanand commented Jul 22, 2016

@freeseacher Compose 1.8 and Engine 1.12 in normal (non-swarm) mode still work fine together, so backward compatibility has been 100% preserved - if you've seen behaviour in the RCs that suggests otherwise, please open an issue for it.

@jalenyang

This comment has been minimized.

Copy link

@jalenyang jalenyang commented Aug 1, 2016

when will docker compose support the integration of docker in swarm model?

@mmiglier

This comment has been minimized.

Copy link

@mmiglier mmiglier commented Sep 1, 2016

Hi,

according to the doc compose should work with swarm mode. However I cannot make it work, here are is my try:

$ docker -v
Docker version 1.12.0, build 8eab29e

$ docker-machine -v
docker-machine version 0.8.1, build 41b3b25

$ docker-machine create --driver virtualbox manager1
Running pre-create checks...
Creating machine...
(manager1) Copying /Users/mmiglier/.docker/machine/cache/boot2docker.iso to /Users/mmiglier/.docker/machine/machines/manager1/boot2docker.iso...
(manager1) Creating VirtualBox VM...
(manager1) Creating SSH key...
(manager1) Starting the VM...
(manager1) Check network to re-create if needed...
(manager1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager1

$ docker-machine create --driver virtualbox worker1
Running pre-create checks...
Creating machine...
(worker1) Copying /Users/mmiglier/.docker/machine/cache/boot2docker.iso to /Users/mmiglier/.docker/machine/machines/worker1/boot2docker.iso...
(worker1) Creating VirtualBox VM...
(worker1) Creating SSH key...
(worker1) Starting the VM...
(worker1) Check network to re-create if needed...
(worker1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker1

$ eval "$(docker-machine env manager1)"
$ docker-machine ls
NAME       ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
manager1   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.1
worker1    -        virtualbox   Running   tcp://192.168.99.101:2376           v1.12.1

$ docker swarm init --advertise-addr 192.168.99.100
Swarm initialized: current node (by7rw6ua88az3ayypu42l8hpe) is now a manager.

To add a worker to this swarm, run the following command:
    docker swarm join \
    --token SWMTKN-1-0rdc568jregv3ozuv9r5npezox4dndd269pwsu052dpu3qgb7c-3k4flh5i8sr3byjklkp6zvqu6 \
    192.168.99.100:2377

To add a manager to this swarm, run the following command:
    docker swarm join \
    --token SWMTKN-1-0rdc568jregv3ozuv9r5npezox4dndd269pwsu052dpu3qgb7c-8k2juvp536bk0zwmzq8hfms7x \
    192.168.99.100:2377

$ eval "$(docker-machine env worker1)"
$ docker swarm join --token SWMTKN-1-0rdc568jregv3ozuv9r5npezox4dndd269pwsu052dpu3qgb7c-3k4flh5i8sr3byjklkp6zvqu6 192.168.99.100:2377

$ eval "$(docker-machine env manager1)"
$ docker node ls
ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
9cg3wmh7abj910fnrvxf415kh    worker1   Ready   Active
by7rw6ua88az3ayypu42l8hpe *  manager1  Ready   Active        Leader

$ docker-machine env --swarm manager1
Error checking TLS connection: "manager1" is not a swarm master. The --swarm flag is intended for use with swarm masters

What am I doing wrong?

Thanks!

Marco

@prologic

This comment has been minimized.

Copy link

@prologic prologic commented Sep 5, 2016

One issue I've seen in looking into this myself is that I don't see anything in any upcoming Milestones nor can I find any issues that indicate active discussions/development in introducing support for Docker Swarm Mode and Docker Compose. Anyone?

@kevinmartinmauro

This comment has been minimized.

Copy link

@kevinmartinmauro kevinmartinmauro commented Sep 6, 2016

Received this error running "docker-compose bundle":

docker-compose bundle
ERROR: Service 'netstats' doesn't define an image tag. An image name is required to generate a proper image digest for the bundle. Specify an image repo and tag with the 'image' option.

@johnharris85

This comment has been minimized.

Copy link
Contributor

@johnharris85 johnharris85 commented Sep 6, 2016

Bundles use digests to specify the images, and an image only gets a digest once it has been pushed to a Registry.

@ddrozdov

This comment has been minimized.

Copy link

@ddrozdov ddrozdov commented Sep 9, 2016

While the official support for Swarm mode in Docker Compose is still in progress, I've created a simple script that takes docker-compose.yml file and runs docker service commands for you. See https://github.com/ddrozdov/docker-compose-swarm-mode for details.

@weitzj

This comment has been minimized.

Copy link

@weitzj weitzj commented Oct 14, 2016

It would also be nice, if containers inside a docker-compose.yml can attach to an existing docker swarm overlay network.
Right now this does not seem to work, as docker deploy will create new networks for projectName.dba named: projectName_default and any other networks defined in the docker-compose.yml, e.g. projectName_frontend.

  • What I would like is that container can attach to the swarm network frontend
  • This is only possible using docker service create..., but this defeats docker-compose and it's dabs.

The scenario is:

  • Have a global jwilder/nginx-proxy service running with -p 80:80 -p 443:443 and bind-mount of TLS-certs. The nginx proxy runs inside it's own network, frontend and does TLS-termination
  • Add a separate docker-compose with the actual services behind the reverse-proxy, whereas the services, which need tls-termination, attach to the frontend network and their default network.

The other wish would be:

  • docker deploy will not use an existing swarm network, which happens to have the same name (e.g. projectName_default). It is only possible for docker deploy to create such a network.
  • This is fine with me, but it is not clear, whether a docker deploy-created network has the --option=encrypted` or not ?

If somebody could clarify, if docker-compose networks in Swarm-Mode are encrypted, would be nice.

@mursilsayed

This comment has been minimized.

Copy link

@mursilsayed mursilsayed commented Nov 22, 2016

@johnharris85 I think Docker Inc. wanted to quickly come up with a simpler alternative to kubernetes so that it can latch on to the customers who were already familiar with docker and were considering options for container orchestration. That seems to be the most imp reason for releasing swarm mode as part of docker core without thinking about all the scenarios people will come up with in production deployment.

@hamzehkhazaei

This comment has been minimized.

Copy link

@hamzehkhazaei hamzehkhazaei commented Nov 28, 2016

It seems that Docker will make everything compatible with "services" and "swarm-mode". So, soon we should be able to orchestrate complex services using docker-compose that leverages swarm-mode underneath.

@brettdh

This comment has been minimized.

Copy link

@brettdh brettdh commented Nov 29, 2016

@henaras that sounds nice, but speculative. Can you point to any recent developments that make you think that this is coming "soon", as you said?

@kinghuang

This comment has been minimized.

Copy link
Contributor

@kinghuang kinghuang commented Nov 29, 2016

@brettdh Docker 1.13 will add the ability to do stack deployments directly from a Docker Compose file (version 3), instead of just from Docker Application Bundle (.dab) files. See moby/moby#27998 for the PR.

@brettdh

This comment has been minimized.

Copy link

@brettdh brettdh commented Nov 29, 2016

@kinghuang That's great news; thanks for the detail. I do recall seeing that PR, now that you mention it, but I didn't see a new RC for Docker Compose yet, so I wasn't sure what the support was going to be.

I think I'm generally unclear on the exact relationship between bundles, stacks, services, and docker-compose, but I imagine this will become clearer as the 1.13 release comes.

@bruno-lopes

This comment has been minimized.

Copy link

@bruno-lopes bruno-lopes commented Dec 4, 2016

Hoping to see this feature officially supported as soon as possible! Docker Swarm Mode has a lot of advantages like load balancing and rolling updates, and Compose let me define my environment in an easy way, so using the two of them would be really nice!

@srinivasthallapalli

This comment has been minimized.

Copy link

@srinivasthallapalli srinivasthallapalli commented Jan 17, 2017

I am confused with http://docs.master.dockerproject.org/compose/swarm/. This issue and the link attached is contradicting, is n't it?. This link provides the way to use compose with swarm mode. Then what is this issue for? or Am I missing something?

@freeseacher

This comment has been minimized.

Copy link

@freeseacher freeseacher commented Jan 17, 2017

@srinivasthallapalli it seems that there are so many compose names for docker.
And we gone another one in 1.13 that introduces target_num_containers that simply does not exists in that one or libcompose.

@hreeder

This comment has been minimized.

Copy link

@hreeder hreeder commented Feb 10, 2017

@srinivasthallapalli That would appear to refer to swarm as opposed to swarm mode (i.e. the old way of doing things) - from that page if you click the link mentioning Docker Swarm, you get presented with this message:

Advisory: See Swarm mode overview for the orchestration features introduced in Docker Engine 1.12. Only refer to the Docker Swarm documents below for information on the standalone Swarm product.

@pestrov

This comment has been minimized.

Copy link

@pestrov pestrov commented Mar 17, 2017

Since Docker 1.13 you can use --compose-file option to deploy docker-compose in the swarm mode like this:
docker stack deploy --compose-file=docker-compose.yml my_stack

https://blog.docker.com/2017/01/whats-new-in-docker-1-13/

@JeremyRubin

This comment has been minimized.

Copy link

@JeremyRubin JeremyRubin commented Mar 27, 2017

Please close? It sounds like @pestrov has responded with a fix.

@shin-

This comment has been minimized.

Copy link
Contributor

@shin- shin- commented Mar 28, 2017

Thanks everyone. As @pestrov pointed out, use docker stack and Compose file v3 for Swarm mode. See the docs for more info.

@shin- shin- closed this Mar 28, 2017
@vjroxvijay1

This comment has been minimized.

Copy link

@vjroxvijay1 vjroxvijay1 commented May 7, 2018

Hello Folks,
I understand that the issue is marked as resolved by referencing "docker stack deploy" command. But can someone explain how it fits into the ansible scripting. I am currently using docker_service command in ansible to deploy to swarm cluster and it always gets deployed as docker run containers because of docker-compose. Any help in deployment to swarm cluster through ansbile will be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.