Rabbitmq: Is it possible to enable the plugins on startup via docker compose?

Created on 23 May 2018  路  8Comments  路  Source: docker-library/rabbitmq

My compose file looks like this...

version: '3'
services:
  rabbit:
    image: "rabbitmq"
    container_name: rabbit
    ports:
    - "5672:5672"
    - "15672:15672"
    volumes:
    - "$PWD/rabbitmq/data/log:/data/log"
    - "$PWD/rabbitmq/data/mnesia:/data/mnesia"
# the following doesn't work, as it thinks its a directory....
    - "$PWD/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins"

and i would like to enable the AMQP 1.0 protocol, which is one of the 'approved' plugins that (according to documentation) comes bundled with it.

Is there a way to enable this plugin by default (through argument, env var or conf file maybe?) when docker compose is started?

Most helpful comment

  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

All 8 comments

Does $PWD/rabbitmq/enabled_plugins exist before starting the container? Docker will create it as a directory if it does not exist on the host first.

You can also edit (generate) the file that contains the list of enabled plugins, in this case /etc/rabbitmq/enabled_plugins. It's an Erlang list of atoms followed by a dot. There is nothing wrong with modifying that file during deployment before the node is started.

- https://github.com/docker-library/rabbitmq/issues/145#issuecomment-291476039

Yes, it does, that's the odd thing...

/dev/spike-rabbit/rabbitmq> ls                                                                        
total 32
drwxr-xr-x  5  staff   160B 23 May 17:14 ./
drwxr-xr-x  7  staff   224B 23 May 17:08 ../
-rw-r--r--@ 1 staff   8.0K 23 May 17:23 .DS_Store
drwxr-xr-x  5  staff   160B 23 May 17:14 data/
-rw-r--r--  1  staff    72B 23 May 17:17 enabled_plugins

the content of enabled_plugins....

[rabbitmq_management,rabbitmq_management_visualiser, rabbitmq_amqp1_0].

and the runtime error....

> docker-compose up
Starting rabbit ... error
ERROR: for rabbit  Cannot start service rabbit: OCI runtime create failed: 
container_linux.go:348: starting container process caused "process_linux.go:402: 
container init caused \"rootfs_linux.go:58: 
mounting \\\"//dev/mtc/spike-rabbit/rabbitmq/enabled_plugins\\\" to rootfs 
\\\"/var/lib/docker/overlay2/49295881d7680ecb1f7d289666d84c35cf05e5476276ad1a286bfdc7bc6e7374/merged\\\" at 
\\\"/var/lib/docker/overlay2/49295881d7680ecb1f7d289666d84c35cf05e5476276ad1a286bfdc7bc6e7374/merged/etc/rabbitmq/enabled_plugins\\\" caused \\\"not a directory\\\"\"":
 unknown: Are you trying to mount a directory onto a file (or vice-versa)? 
Check if the specified host path exists and is the expected type

Are you certain that you are using the image from this repo? The Dockerfile does not use anything from /data, but instead uses a volume at /var/lib/rabbitmq. Have you checked inside the image to see if enabled_plugins is a file (or non-existent) and not a folder?

$ docker pull rabbitmq:3.7.5
3.7.5: Pulling from library/rabbitmq
f2aa67a397c4: Pull complete 
f062288ad968: Pull complete 
8b9469379b84: Pull complete 
5b66af38c756: Pull complete 
d942356ed811: Pull complete 
dd730b88925c: Pull complete 
353d0c7f2496: Pull complete 
8f664faefe5e: Pull complete 
e52f50b7979d: Pull complete 
c785d5ce338c: Pull complete 
be6d0e07a9f4: Pull complete 
31cf1b609ffd: Pull complete 
Digest: sha256:e9c89a727063acfdbcf885e22f0035072dc1faac2b7737da187af3685b24ea52
Status: Downloaded newer image for rabbitmq:3.7.5
$ docker run -it --rm rabbitmq:3.7.5 ls -al /etc/rabbitmq/
total 8
drwxrwsrwx 1 rabbitmq rabbitmq 4096 May 10 03:05 .
drwxr-xr-x 1 root     root     4096 May 24 21:09 ..

I am unable to reproduce the observed failure:

$ echo '[rabbitmq_management,rabbitmq_management_visualiser, rabbitmq_amqp1_0].' > enabled_plugins
$ docker run -it --rm -v "$PWD/enabled_plugins:/etc/rabbitmq/enabled_plugins" rabbitmq:3.7.5
2018-05-24 21:03:24.836 [info] <0.33.0> Application lager started on node rabbit@3b6637744abf
2018-05-24 21:03:24.967 [info] <0.33.0> Application xmerl started on node rabbit@3b6637744abf
2018-05-24 21:03:24.967 [info] <0.33.0> Application recon started on node rabbit@3b6637744abf
2018-05-24 21:03:25.022 [info] <0.33.0> Application mnesia started on node rabbit@3b6637744abf
2018-05-24 21:03:25.057 [info] <0.33.0> Application inets started on node rabbit@3b6637744abf
2018-05-24 21:03:25.057 [info] <0.33.0> Application crypto started on node rabbit@3b6637744abf
2018-05-24 21:03:25.057 [info] <0.33.0> Application amqp10_common started on node rabbit@3b6637744abf
2018-05-24 21:03:25.057 [info] <0.33.0> Application jsx started on node rabbit@3b6637744abf
2018-05-24 21:03:25.059 [info] <0.33.0> Application os_mon started on node rabbit@3b6637744abf
2018-05-24 21:03:25.059 [info] <0.33.0> Application cowlib started on node rabbit@3b6637744abf
2018-05-24 21:03:25.059 [info] <0.33.0> Application asn1 started on node rabbit@3b6637744abf
2018-05-24 21:03:25.060 [info] <0.33.0> Application public_key started on node rabbit@3b6637744abf
2018-05-24 21:03:25.089 [info] <0.33.0> Application ssl started on node rabbit@3b6637744abf
2018-05-24 21:03:25.091 [info] <0.33.0> Application ranch started on node rabbit@3b6637744abf
2018-05-24 21:03:25.092 [info] <0.33.0> Application ranch_proxy_protocol started on node rabbit@3b6637744abf
2018-05-24 21:03:25.093 [info] <0.33.0> Application cowboy started on node rabbit@3b6637744abf
2018-05-24 21:03:25.093 [info] <0.33.0> Application rabbit_common started on node rabbit@3b6637744abf
2018-05-24 21:03:25.098 [info] <0.33.0> Application amqp_client started on node rabbit@3b6637744abf
2018-05-24 21:03:25.104 [info] <0.194.0> 
 Starting RabbitMQ 3.7.5 on Erlang 20.3.5
 Copyright (C) 2007-2018 Pivotal Software, Inc.
 Licensed under the MPL.  See http://www.rabbitmq.com/

  ##  ##
  ##  ##      RabbitMQ 3.7.5. Copyright (C) 2007-2018 Pivotal Software, Inc.
  ##########  Licensed under the MPL.  See http://www.rabbitmq.com/
  ######  ##
  ##########  Logs: <stdout>

              Starting broker...
2018-05-24 21:03:25.113 [info] <0.194.0> 
 node           : rabbit@3b6637744abf
 home dir       : /var/lib/rabbitmq
 config file(s) : /etc/rabbitmq/rabbitmq.conf
 cookie hash    : ZuULuWqEPwfwaqn+OeDEug==
 log(s)         : <stdout>
 database dir   : /var/lib/rabbitmq/mnesia/rabbit@3b6637744abf
2018-05-24 21:03:26.224 [info] <0.202.0> Memory high watermark set to 12643 MiB (13257608396 bytes) of 31608 MiB (33144020992 bytes) total
2018-05-24 21:03:26.226 [info] <0.204.0> Enabling free disk space monitoring
2018-05-24 21:03:26.226 [info] <0.204.0> Disk free limit set to 50MB
2018-05-24 21:03:26.227 [info] <0.206.0> Limiting to approx 1048476 file handles (943626 sockets)
2018-05-24 21:03:26.228 [info] <0.207.0> FHC read buffering:  OFF
2018-05-24 21:03:26.228 [info] <0.207.0> FHC write buffering: ON
2018-05-24 21:03:26.228 [info] <0.194.0> Node database directory at /var/lib/rabbitmq/mnesia/rabbit@3b6637744abf is empty. Assuming we need to join an existing cluster or initialise from scratch...
2018-05-24 21:03:26.228 [info] <0.194.0> Configured peer discovery backend: rabbit_peer_discovery_classic_config
2018-05-24 21:03:26.228 [info] <0.194.0> Will try to lock with peer discovery backend rabbit_peer_discovery_classic_config
2018-05-24 21:03:26.228 [info] <0.194.0> Peer discovery backend does not support locking, falling back to randomized delay
2018-05-24 21:03:26.229 [info] <0.194.0> Peer discovery backend rabbit_peer_discovery_classic_config does not support registration, skipping randomized startup delay.
2018-05-24 21:03:26.229 [info] <0.194.0> All discovered existing cluster peers: 
2018-05-24 21:03:26.229 [info] <0.194.0> Discovered no peer nodes to cluster with
2018-05-24 21:03:26.230 [info] <0.33.0> Application mnesia exited with reason: stopped
2018-05-24 21:03:26.237 [info] <0.33.0> Application mnesia started on node rabbit@3b6637744abf
2018-05-24 21:03:26.273 [info] <0.194.0> Waiting for Mnesia tables for 30000 ms, 9 retries left
2018-05-24 21:03:26.307 [info] <0.194.0> Waiting for Mnesia tables for 30000 ms, 9 retries left
2018-05-24 21:03:26.328 [info] <0.194.0> Waiting for Mnesia tables for 30000 ms, 9 retries left
2018-05-24 21:03:26.328 [info] <0.194.0> Peer discovery backend rabbit_peer_discovery_classic_config does not support registration, skipping registration.
2018-05-24 21:03:26.328 [info] <0.194.0> Priority queues enabled, real BQ is rabbit_variable_queue
2018-05-24 21:03:26.330 [info] <0.381.0> Starting rabbit_node_monitor
2018-05-24 21:03:26.349 [info] <0.194.0> message_store upgrades: 1 to apply
2018-05-24 21:03:26.350 [info] <0.194.0> message_store upgrades: Applying rabbit_variable_queue:move_messages_to_vhost_store
2018-05-24 21:03:26.350 [info] <0.194.0> message_store upgrades: No durable queues found. Skipping message store migration
2018-05-24 21:03:26.350 [info] <0.194.0> message_store upgrades: Removing the old message store data
2018-05-24 21:03:26.350 [info] <0.194.0> message_store upgrades: All upgrades applied successfully
2018-05-24 21:03:26.370 [info] <0.194.0> Management plugin: using rates mode 'basic'
2018-05-24 21:03:26.371 [info] <0.194.0> Adding vhost '/'
2018-05-24 21:03:26.378 [info] <0.417.0> Making sure data directory '/var/lib/rabbitmq/mnesia/rabbit@3b6637744abf/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L' for vhost '/' exists
2018-05-24 21:03:26.379 [info] <0.417.0> Starting message stores for vhost '/'
2018-05-24 21:03:26.379 [info] <0.421.0> Message store "628WB79CIFDYO9LJI6DKMI09L/msg_store_transient": using rabbit_msg_store_ets_index to provide index
2018-05-24 21:03:26.380 [info] <0.417.0> Started message store of type transient for vhost '/'
2018-05-24 21:03:26.380 [info] <0.424.0> Message store "628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent": using rabbit_msg_store_ets_index to provide index
2018-05-24 21:03:26.380 [warning] <0.424.0> Message store "628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent": rebuilding indices from scratch
2018-05-24 21:03:26.381 [info] <0.417.0> Started message store of type persistent for vhost '/'
2018-05-24 21:03:26.381 [info] <0.194.0> Creating user 'guest'
2018-05-24 21:03:26.383 [info] <0.194.0> Setting user tags for user 'guest' to [administrator]
2018-05-24 21:03:26.384 [info] <0.194.0> Setting permissions for 'guest' in '/' to '.*', '.*', '.*'
2018-05-24 21:03:26.385 [info] <0.462.0> started TCP Listener on [::]:5672
2018-05-24 21:03:26.387 [info] <0.194.0> Setting up a table for connection tracking on this node: tracked_connection_on_node_rabbit@3b6637744abf
2018-05-24 21:03:26.388 [info] <0.194.0> Setting up a table for per-vhost connection counting on this node: tracked_connection_per_vhost_on_node_rabbit@3b6637744abf
2018-05-24 21:03:26.389 [info] <0.33.0> Application rabbit started on node rabbit@3b6637744abf
2018-05-24 21:03:26.389 [info] <0.33.0> Application rabbitmq_amqp1_0 started on node rabbit@3b6637744abf
2018-05-24 21:03:26.390 [info] <0.33.0> Application rabbitmq_management_agent started on node rabbit@3b6637744abf
2018-05-24 21:03:26.390 [info] <0.33.0> Application rabbitmq_web_dispatch started on node rabbit@3b6637744abf
2018-05-24 21:03:26.409 [info] <0.520.0> Management plugin started. Port: 15672
2018-05-24 21:03:26.409 [info] <0.626.0> Statistics database started.
2018-05-24 21:03:26.409 [info] <0.33.0> Application rabbitmq_management started on node rabbit@3b6637744abf
 completed with 4 plugins.
2018-05-24 21:03:26.496 [info] <0.5.0> Server startup complete; 4 plugins started.
 * rabbitmq_management
 * rabbitmq_web_dispatch
 * rabbitmq_management_agent
 * rabbitmq_amqp1_0
^CStopping and halting node rabbit@3b6637744abf ...

bingo.

i translated what you did into my compose file, and it's working.

The only real difference being that the enabled_plugins file is at the root with the compose file, rather than 1 directory deep. If i push it 1 directory deep, it fails again, but when in same location as compose file, it works.

Thanks for your help with this, it's appreciated.

Not certain how we fixed it (since host file location shouldn't affect this), but glad it is working.

I moved up a directory and it still worked fine.

$ docker run -it --rm -v "$PWD/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins" rabbitmq:3.7.5

bingo.

i translated what you did into my compose file, and it's working.

The only real difference being that the enabled_plugins file is at the root with the compose file, rather than 1 directory deep. If i push it 1 directory deep, it fails again, but when in same location as compose file, it works.

Thanks for your help with this, it's appreciated.

Can you share your translated docker-compose file?

@thiagoufg sure...

version: '3'
services:
  sqldb:
    image: "microsoft/mssql-server-linux:2017-GDR"
    container_name: mtc_mssql
    ports:
    - "1433:1433"
    environment:
        SA_PASSWORD: "mypassword"
        ACCEPT_EULA: "Y"
        HOMEBREW_NO_ENV_FILTERING: 1
  rabbit:
    image: "rabbitmq"
    container_name: rabbit
    ports:
    - "5672:5672"
    - "15672:15672"
    volumes:
    - "$PWD/rabbitmq/data/log:/data/log"
    - "$PWD/rabbitmq/data/mnesia:/data/mnesia"
    - "$PWD/rabbit_enabled_plugins:/etc/rabbitmq/enabled_plugins"
  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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelklishin picture michaelklishin  路  4Comments

CVTJNII picture CVTJNII  路  6Comments

yidasanqian picture yidasanqian  路  3Comments

mixxit picture mixxit  路  5Comments

michaelklishin picture michaelklishin  路  4Comments