atkayla
atkayla

Reputation: 8859

How to add plugin to RabbitMQ docker image?

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?

Upvotes: 69

Views: 38766

Answers (9)

yannis_t
yannis_t

Reputation: 29

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

Upvotes: 0

angularsen
angularsen

Reputation: 8698

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

Upvotes: 5

Martin Larizzate
Martin Larizzate

Reputation: 910

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!

Upvotes: 3

Duccio Giovannelli
Duccio Giovannelli

Reputation: 329

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

Upvotes: 17

cdev
cdev

Reputation: 5421

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

Upvotes: 12

gsajwan
gsajwan

Reputation: 179

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

Upvotes: 5

Sarvar Nishonboyev
Sarvar Nishonboyev

Reputation: 13110

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

Upvotes: 29

Vincent C.
Vincent C.

Reputation: 867

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.

Upvotes: 33

atkayla
atkayla

Reputation: 8859

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

Upvotes: 49

Related Questions