1. nginx : docker stack deploy -c docker-compose.yml nginx
version: '3.8' services: mq: image: nginx networks: - rabbitmq_network deploy: mode: replicated replicas: 1networks:
rabbitmq_network:
external: true
2. centos: docker stack deploy -c docker-compose.yml centos
version: '3.8' services: centos: image: centos command: /bin/sh -c "while true;do echo hello;sleep 5;done" networks: - rabbit_rabbitmq_network deploy: mode: replicated replicas: 1networks:
rabbit_rabbitmq_network:
external: true
3. docker stack deploy -c docker-compose.yml rabbit
version: '3.8' services: mq: image: rabbitmq:3.9-management environment: RABBITMQ_ERLANG_COOKIE: qqqqq restart: always ports: - 15672:15672 networks: - rabbitmq_network deploy: mode: replicated replicas: 3networks:
rabbitmq_network:
docker stack 一一启动。
进入centos, [root@0517818a6ab6 /]# curl nginx_mq 成功