编写时间:2020-05-08docker
参考文档:docker安装rabbitmq浏览器
1. 编写docker-compose.ymlapp
version: '3' services: rabbitmq: image: rabbitmq:3.8.3-management container_name: rabbitmq restart: always hostname: myRabbitmq ports: - 15672:15672 - 5672:5672 volumes: - ./data:/var/lib/rabbitmq environment: - RABBITMQ_DEFAULT_USER=root - RABBITMQ_DEFAULT_PASS=root
2. 浏览器访问 ip:15672便可,用户名,密码输入root登陆。dom
注意:this
1. application.yml文件中推荐为docker容器设置hostname,由于rabbitmq默认使用hostname做为存储数据的节点名,设置hostname能够避免生成随机的节点名,方便追踪数据。官网原文以下spa
One of the important things to note about RabbitMQ is that it stores data based on what it calls the "Node Name", which defaults to the hostname. What this means for usage in Docker is that we should specify
-h
/--hostname
explicitly for each daemon so that we don't get a random hostname and can keep track of our data:rest
2. RABBITMQ_DEFAULT_USER 和 RABBITMQ_DEFAULT_PASS 用来设置超级管理员的帐号和密码,若是不设置,默认都是 guestcode
3. docker镜像使用像这样 rabbitmq:3.8.3-management 带有后缀 -management的镜像,以前使用没带这个后缀的镜像,网页访问失败,以下图。blog