如何向 RabbitMQ docker 镜像添加插件?

问题描述 投票:0回答:8

我正在使用来自

https://hub.docker.com/_/rabbitmq/
rabbitmq:3-management 但是,它缺少我需要的插件
rabbitmq_delayed_message_exchange

如果图像中没有该插件,如何启用该插件?

docker rabbitmq
8个回答
43
投票
FROM rabbitmq:3.7-management

RUN apt-get update && \
apt-get install -y curl unzip

RUN curl https://dl.bintray.com/rabbitmq/community-plugins/3.7.x/rabbitmq_delayed_message_exchange/rabbitmq_delayed_message_exchange-20171201-3.7.x.zip > rabbitmq_delayed_message_exchange-20171201-3.7.x.zip && \
unzip rabbitmq_delayed_message_exchange-20171201-3.7.x.zip && \
rm -f rabbitmq_delayed_message_exchange-20171201-3.7.x.zip && \
mv rabbitmq_delayed_message_exchange-20171201-3.7.x.ez plugins/

RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange

25
投票

只是更新已接受的答案。您可以将下载的插件复制到rabbitmq镜像中并安装。

插件下载链接:https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases

1。准备自定义图像:

Dockerfile

  FROM rabbitmq:3.7.18-management
  COPY ./rabbitmq_delayed_message_exchange-20171201-3.7.x.ez /opt/rabbitmq/plugins/
  RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange

docker-compose.yml

rabbitmq:
  image: rabbitmq-custom
  ports:
    - "5672:5672"
    - "15672:15672"

2。构建图像

docker build -t rabbitmq-custom .

3.运行 docker 作曲家:

docker-compose up

24
投票

根据https://hub.docker.com/_/rabbitmq,似乎这里还没有唤起第二个选项。 我觉得接受的答案是最好的解决方案,因为它允许更多的调整,但人们可能更喜欢另一种方法:

启用插件

[已接受答案...]

您还可以在

/etc/rabbitmq/enabled_plugins
挂载一个文件,其内容为以句点结尾的 erlang 原子列表。

示例

enabled_plugins

[rabbitmq_federation_management,rabbitmq_management,rabbitmq_mqtt,rabbitmq_stomp].

免责声明:我还没有尝试过。


11
投票

这就是我在3.9版本中实现的方法

FROM rabbitmq:3.9-management

COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf

RUN apt-get -o Acquire::Check-Date=false update && apt-get install -y curl

RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/3.9.0/rabbitmq_delayed_message_exchange-3.9.0.ez > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez

RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez

RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange

9
投票

希望这也有帮助:

rabbitmq3:
  container_name: "rabbitmq"
  image: rabbitmq:3.8-management-alpine
  environment:
    - RABBITMQ_DEFAULT_USER=local
    - RABBITMQ_DEFAULT_PASS=localpwd
    - RABBITMQ_PLUGINS_DIR=/opt/rabbitmq/plugins:/usr/lib/rabbitmq/plugins
  ports:
    # AMQP protocol port
    - '5672:5672'
    # HTTP management UI
    - '15672:15672'
  volumes:
    - ./rabbit/enabled_plugins:/etc/rabbitmq/enabled_plugins
    - ./rabbit/plugins:/usr/lib/rabbitmq/plugins

在 docker-compose 的同一路径中添加一个“rabbit”文件夹,其中包含一个名为 enabled_plugins

的文件
[rabbitmq_management, rabbitmq_message_deduplication].

然后在插件文件夹(“rabbit”文件夹内)中下载您需要的插件 .ez-VERSION。

https://github.com/noxdafox/rabbitmq-message-deduplication/releases


3
投票

如果您已经有一个正在运行的容器,那么只需运行即可

docker exec -it NameOfContainer bash

就我而言,我需要启用 rabbitmq_jms_topic_exchange

rabbitmq-plugins启用rabbitmq_jms_topic_exchange


2
投票

只是为了从官方位置获取插件,我建议下一个 Dockerfile

FROM rabbitmq:3.10-management-alpine

RUN apk --no-cache add curl

RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/3.10.2/rabbitmq_delayed_message_exchange-3.10.2.ez > rabbitmq_delayed_message_exchange-3.10.2.ez && \
mv rabbitmq_delayed_message_exchange-3.10.2.ez plugins/

RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange

希望对你有用!


0
投票

另一种选择是使用 masstransit/rabbitmq,它会定期更新并包含插件。

© www.soinside.com 2019 - 2024. All rights reserved.