welcome here!
当你觉得不行的时候,就去路上走一走,这样你就是一个行人了

Docker部署单机Rabbitmq

Docker环境部署准备

1.基础环境

[root@centos-7 ~]#cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[root@centos-7 ~]#docker --version
Docker version 19.03.12, build 48a66213fe

2.查看RabbitMQ版本

[root@centos-7 ~]#docker search RabbitMQ
NAME                                        DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
rabbitmq                                    RabbitMQ is an open source multi-protocol me…   3358                [OK]                
bitnami/rabbitmq                            Bitnami Docker Image for RabbitMQ               52                                      [OK]
tutum/rabbitmq                              Base docker image to run a RabbitMQ server      20                                      
kbudde/rabbitmq-exporter                    rabbitmq_exporter for prometheus                13                                      [OK]
frodenas/rabbitmq                           A Docker Image for RabbitMQ                     12                                      [OK]
cyrilix/rabbitmq-mqtt                       RabbitMQ MQTT Adapter                           9                                       [OK]
arm32v7/rabbitmq                            RabbitMQ is an open source multi-protocol me…   7                                       
arm64v8/rabbitmq                            RabbitMQ is an open source multi-protocol me…   5   
······

3.获取RabbitMQ最新镜像

[root@centos-7 ~]#docker pull rabbitmq:latest
latest: Pulling from library/rabbitmq
f08d8e2a3ba1: Downloading  8.584MB
3baa9cb2483b: Download complete 
f08d8e2a3ba1: Pull complete 
3baa9cb2483b: Pull complete 
94e5ff4c0b15: Pull complete 
1860925334f9: Pull complete 
b6e36f28fd4a: Pull complete 
1e6be3541bd4: Pull complete 
2c907953f9c1: Pull complete 
3740eb0c71c7: Pull complete 
295add2887ed: Pull complete 
850ed4d559eb: Pull complete 
b6c0fdc08bf3: Pull complete 
Digest: sha256:11b1b3443e1110591a1ab09ecd229669712161e21e7fdaff98575a4af09c8311
Status: Downloaded newer image for rabbitmq:latest
docker.io/library/rabbitmq:latest

4.查看本地下载镜像

[root@centos-7 ~]#docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
rabbitmq            latest              ea2a13ef38ba        3 days ago          156MB
hello-world         latest              bf756fb1ae65        8 months ago        13.3kB

5.运行镜像

[root@centos-7 ~]#docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 -v `pwd`/data:/var/lib/rabbitmq --hostname myRabbit -e RABBITMQ_DEFAULT_VHOST=my_vhost -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=123456 ea2a13ef38ba

参数说明参考:

参数说明:
-d 后台运行容器;
–name 指定容器名;
-p 指定服务运行的端口(5672:应用访问端口;15672:控制台Web端口号);
-v 映射目录或文件;
–hostname 主机名(RabbitMQ的一个重要注意事项是它根据所谓的 “节点名称” 存储数据,默认为主机名);
-e 指定环境变量;(RABBITMQ_DEFAULT_VHOST:默认虚拟机名;RABBITMQ_DEFAULT_USER:默认的用户名;RABBITMQ_DEFAULT_PASS:默认用户名的密码)
ea2a13ef38ba 表示镜像的ID

6.Docker run 后,使用docker ps 查看在运行中也存在RabbitMQ。web界面无法访问,需要进入进行配置

进入RabbitMQ

[root@centos-7 ~]#docker exec -it rabbitmq /bin/bash
root@myRabbit:/# 

开启web管理页面

在容器里面操作:
root@myRabbit:/# rabbitmq-plugins enable rabbitmq_management
root@myRabbit:/# exit            #退出容器

7.rabbitmq设置docker 运行自启动,先找到对应的rabbitmq的镜像ID

[root@centos-7 ~]#docker ps -a 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                                                                                              NAMES
8513760b75a1        ea2a13ef38ba        "docker-entrypoint.s…"   About an hour ago   Up About an hour         4369/tcp, 0.0.0.0:5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   rabbitmq
9e10e2045498        hello-world         "/hello"                 2 hours ago         Exited (0) 2 hours ago                                                                                                      blissful_swartz

8.设置RabbitMQ自启动

[root@centos-7 ~]#docker update 23365f7f39b2 --restart=always

9.重启docker

[root@centos-7 ~]#systemctl restart docker 

10.查看在运行容器

[root@centos-7 ~]#docker ps

11.最后访问rabbitmq的WEB界面
http://IP:15672/

账号为admin 密码为123456
在这里插入图片描述

赞(0) 打赏
开源学习 相互进步www.likai.tech » Docker部署单机Rabbitmq
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

点赞是最好的支持

微信扫一扫打赏