docker-compose.yml文件
version: '3.3'
services:
#rabbitmq container
rabbit1:
#use docker images
image: rabbitmq:3.8.0-management
#container name
container_name: rabbitmq1
#setup host name
hostname: rabbit1
##配置默认账号
environment:
- RABBITMQ_DEFAULT_VHOST=/
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=admin
#- RABBITMQ_NODENAME=rabbit1
- RABBITMQ_ERLANG_COOKIE=rabbitcookie
#ports setting
ports:
- 15672:15672
- 5672:5672
#关机或者重启docker同时重启容器
restart: always
#volumes setting
volumes:
- D:/rabbitmq1/conf:/etc/rabbitmq
- D:/rabbitmq1/log:/var/log/rabbitmq/log
#rabbitmq container
rabbit2:
#use docker images
image: rabbitmq:3.8.0-management
#container name
container_name: rabbitmq2
#setup host name
hostname: rabbit2
#容器启动顺序
depends_on:
- rabbit1
##配置默认账号
environment:
- RABBITMQ_DEFAULT_VHOST=/
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=admin
- CLUSTERED=true
- CLUSTER_WITH=rabbit1
#- RABBITMQ_NODENAME=rabbit2
- RABBITMQ_ERLANG_COOKIE=rabbitcookie
links:
- rabbit1
#ports setting
ports:
- 15673:15672
- 5673:5672
#关机或者重启docker同时重启容器
restart: always
#volumes setting
volumes:
- D:/rabbitmq2/conf:/etc/rabbitmq
- D:/rabbitmq2/log:/var/log/rabbitmq/log
#rabbitmq container
rabbit3:
#use docker images
image: rabbitmq:3.8.0-management
#container name
container_name: rabbitmq3
#setup host name
hostname: rabbit3
#容器启动顺序
depends_on:
- rabbit1
- rabbit2
##配置默认账号
environment:
- RABBITMQ_DEFAULT_VHOST=/
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=admin
- CLUSTERED=true
- CLUSTER_WITH=rabbit1
#- RABBITMQ_NODENAME=rabbit3
- RABBITMQ_ERLANG_COOKIE=rabbitcookie
#容器连接问题
links:
- rabbit1
- rabbit2
#ports setting
ports:
- 15674:15672
- 5674:5672
#关机或者重启docker同时重启容器
restart: always
#volumes setting
volumes:
- D:/rabbitmq3/conf:/etc/rabbitmq
- D:/rabbitmq3/log:/var/log/rabbitmq/log
# docker-compose -f docker-compose-dev.yml up -d
# docker exec -it rabbitmq1 bash
# rabbitmq-plugins enable rabbitmq_management
# exit
# docker exec -it myrabbit6 bash
# rabbitmq-plugins enable rabbitmq_management
# rabbitmqctl reset
# rabbitmqctl stop_app
# exit
执行文件创建集群
docker-compose -f docker-compose.yml up -d