How to Add RabbitMQ Plugins on Docker

Hello,

I’m a Newbe with Docker and I need your kind help with adding a Plugin to the RabbitMQ running on Docker.

I’m running RabbitMQ on Docker on Ubuntu 14.04 LTS.

I would like to add the “rabbitmq_delayed_message_exchange” on my RabbitMQ that is running on Docker, but it seems that I don’t know how to do so.

From my understanding, I need to remove the current running RabbitMQ container and add a new one which includes this plugin. Isn’t there a smarter way to add the plugin without removing a running container?
If there is a smarter way, such as running the command below, where should I save the plugin?

Here is the command I am using, and the error I receive. Where should I reside the Plugin?
“docker exec 7b0122d371f3 rabbitmq-plugins enable rabbitmq_delayed_message_exchange”

Response:
“Error: The following plugins could not be found:
rabbitmq_delayed_message_exchange”

Below is the Configuration I ran to build the RabbitMQ on Docker:

docker run -d -h host.docker
–add-host=host.docker:192.168.1.10
–name rabbit
-p “4370:4370”
-p “5672:5672”
-p “15672:15672”
-p “25672:25672”
-p “35197:35197”
-e “RABBITMQ_USE_LONGNAME=true”
-e “ERL_EPMD_PORT=4370”
-e RABBITMQ_ERLANG_COOKIE=“RabitRabit”
-e RABBITMQ_NODENAME=“master”
-e “RABBITMQ_LOGS=/var/log/rabbitmq/rabbit.log”
-v /data/rabbitmq:/var/lib/rabbitmq
-v /data/rabbitmq/logs:/var/log/rabbitmq
rabbitmq:3.6.6-management \

Thanks in advanced for your help.

As a general rule, if you need to change the software running in a container, you should build a new image, stop the running container, and run a new container against the new image. You also need to recreate the container to change a number of routine options (environment variables, port mappings, …) and so you should expect to do this and plan for it.

(I’m seeing a lot of posts these days of the form “oh, I got a shell in the container and…”, but whatever work you do by hand that way will be lost when the container exits, and nobody else on your team can reuse the work you did this way.)

Thank you David,

As my knowledge with Docker is a bit limited, can you share the steps that I need in order to build the new image? It seems I can’t understand how I add the Plugin itself to the RabbitMQ before I create an image out of it to run as a container.

Docker has a very good tutorial on the process. While the tutorial is for a Python application, you can start your Dockerfile FROM any image you’d like, and docker build the new image.

The Dockerfile would just look like

FROM rabbitmq:3.6.6-management
RUN whatever command to install the plugin

You can experiment with and debug this without affecting your running container; if you need to move systems you can just copy the Dockerfile over and rebuild it; and if you need to upgrade RabbitMQ you can change the version in this Dockerfile and rebuild it without having to remember what manual steps you did after you started it up.

Thank you for the explanation.