简体   繁体   English

在群上运行docker compose

[英]running docker compose on swarm

I have a compose file: 我有一个撰写文件:

docker-compose.yml 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>? 会像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. 我可以运行docker -H :4000 run hello-world很好,但是那是docker镜像。 how do you run docker compose across swarm cluster? 如何在整个群集集群中运行docker compose?

ie 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? 即我想compose_openjdk-7u79-jdk_1去一个节点,而compose_openjdk-8u66-jdk_1去另一个节点,依此类推?

According to the documentation you can add contraints to services: 根据文档,您可以向服务添加contraints

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

I have not tested it myself. 我自己还没有测试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM