How to add plugin to RabbitMQ docker image?

14,097

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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

Solution 5

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

Share:
14,097
atkayla
Author by

atkayla

Updated on June 17, 2022

Comments

  • atkayla
    atkayla about 2 years

    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?