# 环境变量可参考: https://www.rabbitmq.com/configure.html
# https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbit/docs/rabbitmq.conf.example
# https://www.rabbitmq.com/clustering.html#erlang-cookie
version: '3'
# 网桥 -> 方便相互通讯
networks:
rabbitmq:
driver: bridge
services:
rabbitmq-1:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.1-management # 镜像`rabbitmq:3.9.1-management` 【 注:该版本包含了web控制页面 】
container_name: rabbitmq-1 # 容器名为'rabbitmq-1'
hostname: my-rabbit-1
restart: unless-stopped # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq-cluster/rabbitmq-1/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- "./rabbitmq-cluster/rabbitmq-1/data:/var/lib/rabbitmq"
- "./rabbitmq-cluster/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez:/opt/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez"
- "./rabbitmq-cluster/.erlang.cookie:/var/lib/rabbitmq/.erlang.cookie"
ports: # 映射端口
- "5672:5672"
- "15672:15672"
networks:
- rabbitmq
rabbitmq-2:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.1-management # 镜像`rabbitmq:3.9.1-management` 【 注:该版本包含了web控制页面 】
container_name: rabbitmq-2 # 容器名为'rabbitmq-2'
hostname: my-rabbit-2
restart: unless-stopped # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq-cluster/rabbitmq-2/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- "./rabbitmq-cluster/rabbitmq-2/data:/var/lib/rabbitmq"
- "./rabbitmq-cluster/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez:/opt/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez"
- "./rabbitmq-cluster/.erlang.cookie:/var/lib/rabbitmq/.erlang.cookie"
ports: # 映射端口
- "5673:5672"
networks:
- rabbitmq