Rabbitmq: if i mount /etc/rabbitmq/rabbitmq.conf the container exit

Created on 29 Nov 2018  路  9Comments  路  Source: docker-library/rabbitmq

hey,

i tried to configure the consul_discovery plugin.

I added those lines to a local rabbitmq.conf and mounted this file as a Volume to my docker Container.

  rabbitmq:
    image: rabbitmq:3.7
    volumes:
      #- ${PWD}/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
      - ${PWD}/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
      - rabbitmq:/var/lib/rabbitmq
cluster_formation.peer_discovery_backend  = rabbit_peer_discovery_consul
cluster_formation.consul.host = consul
cluster_formation.node_cleanup.only_log_warning = true
cluster_formation.consul.svc_addr_auto = true
cluster_partition_handling = autoheal

that brings me to this:

sed: can't move '/etc/rabbitmq/rabbitmq.confDMidAB' to '/etc/rabbitmq/rabbitmq.conf': Resource busy

i also tried to set the config with some environment variables:

    environment:
      - RABBITMQ_VM_MEMORY_HIGH_WATERMARK=0.25
      - RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-cluster_formation peer_discovery_backend rabbit_peer_discovery_consul 
        -cluster_formation consul.host consul 
        -cluster_formation node_cleanup.only_log_warning true"

but it does not work too :-( maybe any one can help me a little bit?

Thanks

Most helpful comment

@wglambert that's because of the quotes -- those are being interpreted via YAML as part of your environment variable value

You should switch to either:

      - 'RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbit channel_max 4007'

or:

      RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '-rabbit channel_max 4007'

(Either of which should work as expected.)

All 9 comments

Gah, I guess we need something like https://github.com/docker-library/cassandra/pull/160. :disappointed:

I disagree needing the solution from cassandra. We added it for cassandra since /etc/cassandra/ has many more required files and folders than just the config yaml, making it very difficult to bind mount the whole directory. This is not the case for rabbitmq, since the directory is empty in the image.

$ docker run -it --rm rabbitmq ls -l /etc/rabbitmq/
total 0
$ docker run -it --rm cassandra ls -l /etc/cassandra/
total 116
-rw-r--r-- 1 cassandra cassandra 12527 Nov 15 00:59 cassandra-env.sh
-rw-r--r-- 1 cassandra cassandra  1200 Jul  2 18:36 cassandra-rackdc.properties
-rw-r--r-- 1 cassandra cassandra  1358 Jul  2 18:36 cassandra-topology.properties
-rw-r--r-- 1 cassandra cassandra 57664 Jul  2 18:36 cassandra.yaml
-rw-r--r-- 1 cassandra cassandra  2082 Jul  2 18:36 commitlog_archiving.properties
-rw-r--r-- 1 cassandra cassandra  2757 Jul  2 18:36 hotspot_compiler
-rw-r--r-- 1 cassandra cassandra  9956 Jul  2 18:36 jvm.options
-rw-r--r-- 1 cassandra cassandra  1195 Jul  2 18:36 logback-tools.xml
-rw-r--r-- 1 cassandra cassandra  3809 Jul  2 18:36 logback.xml
drwxr-xr-x 2 cassandra cassandra  4096 Nov 15 00:59 triggers

@timrosede, Since you already have your conf and enabled plugins in the right folder, you should be able to just use this compose yaml:

  rabbitmq:
    image: rabbitmq:3.7
    volumes:
      - ${PWD}/rabbitmq/:/etc/rabbitmq/
      - rabbitmq:/var/lib/rabbitmq

Using

volumes:
      - ./rabbitmq/:/etc/rabbitmq/

Rabbitmq started fine, the config options you supplied error in my minimal setup of just one rabbitmq:3.7 so I just used channel_max = 4007 as my rabbitmq.conf option

$ ls
docker-compose.yml  rabbitmq/

$ cat rabbitmq/rabbitmq.conf 
channel_max = 4007

$ docker-compose up -d
Creating network "rabbitmq-292_default" with the default driver
Creating rabbitmq-292_rabbitmq_1 ... done

$ docker exec rabbitmq-292_rabbitmq_1 rabbitmqctl environment | grep channel_max
      {channel_max,4007},

It works, but if you set a RABBITMQ_VAR it results in a "permission denied" error for rabittmq.conf.

Could you give the specific example you're using, I noticed RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS isn't interpreted correctly by the entrypoint when in a docker-compose.yml, it see's the -rabbit as an env var, however I don't get any permission error and using other environment variables works fine with a config file being mounted.

Passing the ADDITIONAL_ERL_ARGS to docker run works fine with a config file

$ cat rabbitmq/rabbitmq.conf 
channel_max = 4007

$ docker run -dit --rm --name rabbitmq -v $(pwd)/rabbitmq/:/etc/rabbitmq/ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbit auth_backends [rabbit_auth_backend_ldap,rabbit_auth_backend_internal]" rabbitmq
5fc37d0cb6a5cb3163e261c69dbd49d7411ac8ae08310e061a95b767343338df

$ docker exec rabbitmq rabbitmqctl environment | grep channel_max
      {channel_max,4007},

$ docker exec rabbitmq rabbitmqctl environment | grep auth_backends
     [{auth_backends,[rabbit_auth_backend_ldap,rabbit_auth_backend_internal]},

This is the error with ADDIITONAL_ERL_ARGS in a docker-compose.yml

version: '3.1'

services:
   rabbitmq:
    image: rabbitmq:3.7
    environment:
      - RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbit channel_max 4007"
$ docker-compose up
Recreating rabbitmq-292_rabbitmq_1 ... done
Attaching to rabbitmq-292_rabbitmq_1
rabbitmq_1  | 2018-11-29 18:12:12 application_controller: ~ts: ~ts~n
rabbitmq_1  |   "unterminated string starting with \"-rabbit\""
rabbitmq_1  |   "\"-rabbit"
rabbitmq_1  | {"could not start kernel pid",application_controller,"{bad_environment_value,\"\\"-rabbit\"}"}
rabbitmq_1  | could not start kernel pid (application_controller) ({bad_environment_value,"\"-rabbit"})
rabbitmq_1  | 
rabbitmq_1  | Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
rabbitmq-292_rabbitmq_1 exited with code 0

@wglambert that's because of the quotes -- those are being interpreted via YAML as part of your environment variable value

You should switch to either:

      - 'RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbit channel_max 4007'

or:

      RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '-rabbit channel_max 4007'

(Either of which should work as expected.)

It works, but if you set a RABBITMQ_VAR it results in a "permission denied" error for rabittmq.conf.

In this case, if you set RABBITMQ_xxx, most of those are implemented by changing the configuration. By setting that environment variable, you're asking our entrypoint script to modify the configuration file (which it has to have permission to do, or else it will fail in the way you've described/discovered). If you're already supplying a configuration file, you'd probably be better off just setting your desired configuration directly in your own file instead.

(Closing, since this appears to be resolved.)

same result you can mounting /etc/rabbitmq/advanced.config file into container
Example of advanced.config

[
 {rabbit,
  [%%
   %% cluster_formation.peer_discovery_backend = rabbit_peer_discovery_dns
   %% cluster_formation.dns.hostname = rmq.discovery
   {cluster_formation,
    [
     {peer_discovery_backend, rabbit_peer_discovery_dns},
     {peer_discovery_dns,
      [
       {hostname, "rmq.discovery"}
      ]
     }
    ]
   },

   %% Setting cluster behaviour after split brain
   {cluster_partition_handling, autoheal}
  ]
 }
].
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Thubo picture Thubo  路  6Comments

mixxit picture mixxit  路  5Comments

decaz picture decaz  路  5Comments

michaelkrog picture michaelkrog  路  5Comments

zhousujian picture zhousujian  路  5Comments