准备工作
# 打开docker目录
[root@VM-4-8-centos ~]# cd /usr/local/docker/
# 创建rabbitmq文件夹
[root@VM-4-8-centos docker]# mkdir rabbitmq
# 打开rabbitmq文件夹
[root@VM-4-8-centos docker]# cd rabbitmq/
挂载目录
# 创建挂载目录
[root@VM-4-8-centos rabbitmq]# mkdir data
启动脚本
# 编写脚本
[root@VM-4-8-centos rabbitmq]# vim startRabbitMq.sh
脚本内容
docker run -d \
-v /usr/local/docker/rabbitmq/data:/var/lib/rabbitmq \
-p 5672:5672 -p 15672:15672 \
--name rabbitmq \
--privileged=true \
--restart=always \
--hostname myRabbit rabbitmq:3.9.13-management
权限不足时:
脚本赋权
[root@VM-4-8-centos rabbitmq]# chmod -R 700 startRabbitMq.sh
启动脚本
[root@VM-4-8-centos rabbitmq]# ./startRabbitMq.sh
Unable to find image 'rabbitmq:3.9.13-management' locally
3.9.13: Pulling from library/rabbitmq
4d15b49e6975: Pull complete
2108a12354ce: Pull complete
5c6af9d45693: Pull complete
0f87630b6c7c: Pull complete
9234e199a7d9: Pull complete
efaba59aede6: Pull complete
46802a4f12bc: Pull complete
13b60d6df2ff: Pull complete
ac0786dc13e5: Pull complete
Digest: sha256:f5c8c7fd99e4c88527276df319556fdcb56e4d289614c5fefda5ee8d17c5ea89
Status: Downloaded newer image for rabbitmq:3.9.13-management
ee7636e3d0baa7df4d5490c99616fef006bceedb08c46d7a2fea5650a6f01429
然后还有小操作别忘了重启rabbitmq
输入:docker ps -a查看你所有的容器看看有没有开启
docker start (rabbitmq的id)
过一会重进一次浏览器:你的ip:15672进入rabbitMq
查看结果
用户名:guest
密码:guest
进来之后就代表装好了
版权归原作者 晴晴公猪ovo 所有, 如有侵权,请联系我们删除。