Skip to content

if i mount /etc/rabbitmq/rabbitmq.conf the container exit #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timrosede opened this issue Nov 28, 2018 · 9 comments
Closed

if i mount /etc/rabbitmq/rabbitmq.conf the container exit #292

timrosede opened this issue Nov 28, 2018 · 9 comments

Comments

@timrosede
Copy link

timrosede commented Nov 28, 2018

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

@tianon
Copy link
Member

tianon commented Nov 28, 2018

Gah, I guess we need something like docker-library/cassandra#160. 😞

@yosifkit
Copy link
Member

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

@wglambert
Copy link

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},

@timrosede
Copy link
Author

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

@wglambert
Copy link

wglambert commented Nov 29, 2018

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]},

@wglambert
Copy link

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

@tianon
Copy link
Member

tianon commented Nov 29, 2018

@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.)

@tianon
Copy link
Member

tianon commented Dec 5, 2018

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.)

@tianon tianon closed this as completed Dec 5, 2018
@sergey-safarov
Copy link

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}
  ]
 }
].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants