下载镜像
docker pull rabbitmq:3.8-management
编写docker-compose.yml
version: '3'
services:
rabbit:
image: rabbitmq:3.8-management
hostname: rabbit
container_name: "rabbitmq"
restart: always
ports:
- "8303:5672"
- "8304:15672"
environment:
- RABBITMQ_DEFAULT_USER=root
- RABBITMQ_DEFAULT_PASS=l3c^cYa4
volumes:
- /home/data/rabbitmq:/var/lib/rabbitmq
端口号说明:
- 5672:用于 amqp 协议通信,用于程序连接 rabbitmq 使用。
- 15672:用于 rabbitmq 的 web 管控台访问端口。
RABBITMQ_DEFAULT_USER和RABBITMQ_DEFAULT_PASS就是设置web管控台的默认用户名和密码。
启动服务
docker-compose up -d
启动web监控插件
进入容器
docker exec -it rabbitmq bash
执行启用插件命令
rabbitmq-plugins enable rabbitmq_management
响应信息如下:
Enabling plugins on node rabbit@rabbit:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_prometheus
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@rabbit...
Plugin configuration unchanged.