跨Docker群部署Docker容器

时间:2018-11-23 23:30:01

标签: docker docker-compose docker-swarm

我想在集群的各个节点上部署我的容器。容器在docker-compose中定义。正如他们解释here一样,我设置了环境变量以强制在特定节点上运行容器。

我有以下三个节点:

filip@vehicle1:~/hyperledger_fabric$ docker node list
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
xlvqc2ups1xqq2byphkhpsle4 *   vehicle1            Ready               Active              Leader              18.06.1-ce
m7b3uo7nop9h2kznbaorjzwkh     vehicle2            Ready               Active              Reachable           18.06.1-ce
wlbaalbq7xldark134oyfs2f4     vehicle3            Ready               Active              Reachable           18.06.1-ce

但是在我运行docker-compose之后,我看到我所有的容器都只在节点上运行:vehicle1,而vehicle2,vehicle3中没有。这怎么可能,请您帮助我,我做错了什么?

谢谢

我的docker撰写:

version: '2'

volumes:
  orderer0.example.com:
  orderer1.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer2.org1.example.com:

networks:
  byfn:

services:

  orderer0.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer0.example.com
    container_name: orderer0.example.com
    environment: 
      - "constraint:node==vehicle1"
    depends_on:
      - kafka0.example.com
      - kafka1.example.com
      - kafka2.example.com
    networks:
      - byfn

  orderer1.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer1.example.com
    container_name: orderer1.example.com
    environment: 
      - "constraint:node==vehicle2"
    depends_on:
      - kafka0.example.com
      - kafka1.example.com
      - kafka2.example.com
    networks:
      - byfn      

  orderer2.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer2.example.com
    container_name: orderer2.example.com
    environment: 
      - "constraint:node==vehicle3"
    depends_on:
      - kafka0.example.com
      - kafka1.example.com
      - kafka2.example.com
    networks:
      - byfn 

 .....

0 个答案:

没有答案