1. 虚拟机上新建一个空目录
mkdir rabbitmq
2. 在目录里面新建文件
vim docker-compose.yml
文件的内容如下:
version: '3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=‘username’
- RABBITMQ_DEFAULT_PASS=‘pwd123456’
restart: always
ports:
- 15672:15672
- 5672:5672
logging:
driver: "json-file"
options:
max-size: "500k"
max-file: "10"
volumes:
- ./mqdata:/var/lib/rabbitmq
3. 使用docker-compose命令一步完成安装
docker-compose up -d