How to add plugin to RabbitMQ docker image?
Asked Answered
G

9

64

I am using rabbitmq:3-management from https://hub.docker.com/_/rabbitmq/ however, it is missing a plugin that I need rabbitmq_delayed_message_exchange.

How can I enable this plugin if it is not available in the image?

Godewyn answered 15/10, 2018 at 14:41 Comment(6)
Have you considered creating your own Docker image using the rabbimq:3-management as a base and just installing the plugin?Solvency
@UroshT. Thanks! I've never done that before, but I gave it a shot and posted an answer. It seems to work. How's my custom Docker image look? I found it strange that I had to install basics like curl and unzip.Godewyn
"I found it strange that I had to install basics like curl/unzip" - they're not needed in most images, so why include them?Azalea
@SergioTulentsev Well to install the RabbitMQ plugin it seems like I needed curl to download it, then I had to unzip it to get the .ez file.Godewyn
@kayla but they were not needed to run rabbitmq from the base image, so no wonder they aren't there.Azalea
Yes, Sergio has a point, the images are optimized so that they include only the necessary for deployment of rabbitmq. If it worked, accept your own answer so that the people having the same issue as you know how to solve it.Solvency
G
49
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
Godewyn answered 15/10, 2018 at 15:24 Comment(2)
The Link to the (currently) latest version can be found here: dl.bintray.com/rabbitmq/community-plugins/3.8.x/…Caskey
A built a different version based on @Godewyn one justo to obtain the ez file from official github repository. check here: https://mcmap.net/q/300379/-how-to-add-plugin-to-rabbitmq-docker-imageVaientina
H
29

Just updating the accepted answer. You may copy the downloaded plugin into rabbitmq image and install it.

Plugin download link: https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases

1. Prepare custom image:

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. Build the image

docker build -t rabbitmq-custom .

3. Run the docker composer:

docker-compose up
Hallett answered 2/10, 2019 at 14:28 Comment(0)
H
29

According to https://hub.docker.com/_/rabbitmq it seems there is a second option not yet evoked here. I feel accepted answer is the best solution for it allows more tweaks, but one might prefer the other method:

Enabling Plugins

[Accepted answer...]

You can also mount a file at /etc/rabbitmq/enabled_plugins with contents as an erlang list of atoms ending with a period.

Example enabled_plugins

[rabbitmq_federation_management,rabbitmq_management,rabbitmq_mqtt,rabbitmq_stomp].

DISCLAIMER: I have not tried it yet.

Hopeh answered 24/9, 2020 at 13:6 Comment(3)
This really should be marked as the most effective solution.Nikaniki
This should be the accepted answer. Thanks!Haematoid
I think this solution would only work for the plugins included in rabbitmq by default. The plugin in this question is not one of the core plugins listed here: rabbitmq.com/plugins.htmlWinchell
H
12

This is how I achieved in version 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
Hornbeam answered 17/9, 2021 at 2:51 Comment(0)
L
11

Hope this helps too:

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

Add a "rabbit" folder in the same path of the docker-compose with a file called enabled_plugins

[rabbitmq_management, rabbitmq_message_deduplication].

then download the plugins .ez-VERSION you need in a folder plugins (within "rabbit" folder).

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

Laban answered 6/4, 2022 at 17:54 Comment(1)
RABBITMQ_PLUGINS_DIR=/opt/rabbitmq/plugins:/usr/lib/rabbitmq/plugins this trick helped me to enable pluginLector
S
4

If you have already a running container than simply run

docker exec -it NameOfContainer bash

In mycase I need to enable rabbitmq_jms_topic_exchange

rabbitmq-plugins enable rabbitmq_jms_topic_exchange

Salinasalinas answered 29/3, 2021 at 15:55 Comment(0)
F
4

Another option is to use masstransit/rabbitmq, which is regularly updated and includes the plugin.

Forsterite answered 21/10, 2023 at 22:0 Comment(0)
V
2

Just to get the plugin from the official place I propose the next 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

Hope to be useful!

Vaientina answered 6/9, 2022 at 0:18 Comment(0)
C
0

The answer provided above by @gsajwan requires the container to be restarted in order for the change to take effect.

Verified on version 3.13-management

Caw answered 1/5 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.