我正在使用来自
https://hub.docker.com/_/rabbitmq/的
rabbitmq:3-management
但是,它缺少我需要的插件 rabbitmq_delayed_message_exchange
。
如果图像中没有该插件,如何启用该插件?
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
只是更新已接受的答案。您可以将下载的插件复制到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
根据https://hub.docker.com/_/rabbitmq,似乎这里还没有唤起第二个选项。 我觉得接受的答案是最好的解决方案,因为它允许更多的调整,但人们可能更喜欢另一种方法:
启用插件
[已接受答案...]
您还可以在
挂载一个文件,其内容为以句点结尾的 erlang 原子列表。/etc/rabbitmq/enabled_plugins
示例
enabled_plugins
[rabbitmq_federation_management,rabbitmq_management,rabbitmq_mqtt,rabbitmq_stomp].
免责声明:我还没有尝试过。
这就是我在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
希望这也有帮助:
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
如果您已经有一个正在运行的容器,那么只需运行即可
docker exec -it NameOfContainer bash
就我而言,我需要启用 rabbitmq_jms_topic_exchange
rabbitmq-plugins启用rabbitmq_jms_topic_exchange
只是为了从官方位置获取插件,我建议下一个 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
希望对你有用!
另一种选择是使用 masstransit/rabbitmq,它会定期更新并包含插件。