Docker中安装rabbitmq并启用插件

Posted roobbin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker中安装rabbitmq并启用插件相关的知识,希望对你有一定的参考价值。

1.获取rabbitmq镜像,注意获取镜像的时候要获取management,不要获取last版本,management版本才是带有管理界面的,结果如下

[email protected]:/usr/local/src# docker search rabbitmq:management
NAME                                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
macintoshplus/rabbitmq-management   Based on rabbitmq:management whit python and…   2                                       [OK]
transmitsms/rabbitmq-sharded        Fork of rabbitmq:management with sharded_exc…   0                                       
xiaochunping/rabbitmq               xiaochunping/rabbitmq:management   2018-06-30   0                                       
[email protected]:/usr/local/src# 

2.将rabbitmq镜像pull到本地

[email protected]:/usr/local/src# docker pull rabbitmq:management
management: Pulling from library/rabbitmq
802b00ed6f79: Already exists 
84fe35f04ebe: Already exists 
72a118dc68c2: Already exists 
51c199718697: Already exists 
e74b797281ea: Already exists 
f2b0494f0e3c: Already exists 
d43b5d7d2745: Already exists 
dedfc544656e: Already exists 
ed99f98ab240: Already exists 
422ec57c0d17: Already exists 
85c41b55ab02: Already exists 
8d040d0f68fe: Already exists 
881b91c66b89: Pull complete 
06bcf7b1b9c9: Pull complete 
Digest: sha256:a4ae5d7965167e593299bbc12298614f4f6e339492be21f245592994128047b9
Status: Downloaded newer image for rabbitmq:management

3.启动容器,映射端口,设置默认账户密码

[email protected]:/usr/local/src# docker run -d -p 5672:5672 -p 15672:15672 -p 15674:15674 --name some-rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin rabbitmq:management
4ae3dcacf5b2edf2380a020c7712f4ff7ebe59d602c682e021d5bcaf219cc279

4.创建Dockerfile开启rabbitmq插件,编辑 vim Dockerfile 添加如下内容,保存退出

FROM rabbitmq:management
MAINTAINER xiaoran
RUN rabbitmq-plugins enable --offline rabbitmq_mqtt rabbitmq_federation_management rabbitmq_stomp

5.通过Dockerfile生成镜像,注:这一步必须在启动容器之后执行

[email protected]:/usr/local/src# docker build -f Dockerfile -t rabbitmq:management .
Sending build context to Docker daemon  270.8MB
Step 1/3 : FROM rabbitmq:management
 ---> fd30855d5f94
Step 2/3 : MAINTAINER xiaoran
 ---> Running in 43f00ce98c44
Removing intermediate container 43f00ce98c44
 ---> 901264bebf14
Step 3/3 : RUN rabbitmq-plugins enable --offline rabbitmq_mqtt rabbitmq_federation_management rabbitmq_stomp
 ---> Running in ca9936669ef7
The following plugins have been configured:
  rabbitmq_federation
  rabbitmq_federation_management
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_mqtt
  rabbitmq_stomp
  rabbitmq_web_dispatch
Applying plugin configuration to [email protected]
Plugin configuration unchanged.
Removing intermediate container ca9936669ef7
 ---> e176bdac7eb8
Successfully built e176bdac7eb8
Successfully tagged rabbitmq:management

6.生成镜像后,通过ip:15672访问web界面,

技术分享图片

到此,rabbitmq已完成

以上是关于Docker中安装rabbitmq并启用插件的主要内容,如果未能解决你的问题,请参考以下文章

如何在Docker容器中安装RabbitMQ

如何在Docker容器中安装RabbitMQ

如何在Docker容器中安装RabbitMQ

RabbitMQ 管理插件 - 配置不变

怎么在vmware中安装rabbitmq

无法在 Docker 中部署的 Jenkins 中安装插件