ealeon
ealeon

Reputation: 12462

running docker compose on swarm

I have a compose file:

docker-compose.yml

openjdk-6b36-jdk:
  image: java:openjdk-6b36-jdk
  volumes:
   - ./src:/src
   - ./build/openjdk-6b36-jdk:/build
  command: /src/compileAndTest

openjdk-7u79-jdk:
  image: java:openjdk-7u79-jdk
  volumes:
   - ./src:/src
   - ./build/openjdk-7u79-jdk:/build
  command: /src/compileAndTest

openjdk-8u66-jdk:
  image: java:openjdk-8u66-jdk
  volumes:
   - ./src:/src
   - ./build/openjdk-8u66-jdk:/build
  command: /src/compileAndTest

it runs fine:

-bash-4.2$ docker-compose up
Starting compose_openjdk-7u79-jdk_1
Starting compose_openjdk-8u66-jdk_1
Starting compose_openjdk-6b36-jdk_1
Attaching to compose_openjdk-8u66-jdk_1, compose_openjdk-7u79-jdk_1, compose_openjdk-6b36-jdk_1
openjdk-7u79-jdk_1  | Hello, World
openjdk-8u66-jdk_1  | Hello, World
openjdk-6b36-jdk_1  | Hello, World
compose_openjdk-7u79-jdk_1 exited with code 0
compose_openjdk-8u66-jdk_1 exited with code 0
compose_openjdk-6b36-jdk_1 exited with code 0

i would like to run this across swarm cluster What would be the command to do so?

would it be something like docker -H :4000 run <something>? because that the command i used to run images on swarm nodes

I can run docker -H :4000 run hello-world fine but those are docker images. how do you run docker compose across swarm cluster?

i.e. i want compose_openjdk-7u79-jdk_1 to go to one node and compose_openjdk-8u66-jdk_1 to go to another node and so forth?

Upvotes: 0

Views: 122

Answers (1)

Martin
Martin

Reputation: 3114

According to the documentation you can add contraints to services:

https://docs.docker.com/compose/swarm/#/manual-scheduling

I have not tested it myself.

Upvotes: 1

Related Questions