I am trying to set up a rabbitmq cluster on with aws container service. I need the /var/lib/rabbitmq/.erlang.cookie to be the same on all nodes. So for all my rabbitmq containers when they are run I pass in a RABBITMQ_ERLANG_COOKIE environment variable which according to documentation here https://hub.docker.com/_/rabbitmq/ should be written into /var/lib/rabbitmq/.erlang.cookie.

When I inspect my running container I can see that environment variable RABBITMQ_ERLANG_COOKIE=QOKWQHQKXXTBIEAOPWKE is present but when i cat /var/lib/rabbitmq/.erlang.cookie I get a different value AYMNAPKRPCPJVPFYAJZX.

As a result all rabbitmq containers have different .erlang.cookie and cannot form a cluster.

Why isn't the cookie from environment variable set? What could I be missing here?

I am using rabbitmq:3.6.9-alpine image.

  • 1
    Can you post the task definition? The relevant code is at github.com/docker-library/rabbitmq/blob/master/3.6/alpine/…. I am guessing maybe you are mounting a volume at /var/lib/rabbitmq and maybe the .erlang.cookie already exists and is skipping the environment variable.
    – Andy Shinn
    Apr 10, 2017 at 22:01
  • @AndyShinn this is exactly what happened. I was mounting a volume and i started rabbits without any cluster config at first. So each one created its own .erlang.cookie. Later when I was passing in cookie as env variable it just couldn't write it into the file.
    – raitisd
    Apr 11, 2017 at 11:15

4 Answers 4


I run into this thread when search very similar problem, but my env var is ERLANG_COOKIE, after I changed to use RABBITMQ_ERLANG_COOKIE, it's working like a charm

Here comes my docker-compose about rabbitmq, ${HOST} will be replaced with value set in .env file which lives in the same folder as docker-compose.yml

  image: rabbitmq:3-management
    - "15672:15672"
    - "25672:25672"
    - "5672:5672"
    - "4369:4369"
    - RABBITMQ_ERLANG_COOKIE='takeMyCookies'
  hostname: "${HOST}"

Take a look at the cookie value

root@prod-03:/# cat ~/.erlang.cookie
root@prod-03:/# cat /var/lib/rabbitmq/.erlang.cookie

I had the same error until I configured the cookie value correctly and removed the '-' character from it.

Another way to set it is RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-setcookie cookie-value"


There is a bug in version 3.9 of the RabbitMQ docker image where the RABBITMQ_ERLANG_COOKIE value is not being written to the /var/lib/rabbitmq/.erlang.cookie file in the container. The bug is identified here -> https://github.com/docker-library/rabbitmq/pull/502.

One solution is to use some other version of the RabbitMQ docker image, such as version 3.8.

docker pull rabbitmq:3.8-management

Or, if you must use version 3.9, then you can create the .erlang.cookie file on your Docker system and use the -v or --volume option to mount the .erlang.cookie file on your Docker system to /var/lib/rabbitmq/.erlang.cookie in the container.

docker run --detach --volume /path/to/.erlang.cookie:/var/lib/rabbitmq/.erlang.cookie rabbitmq:management

Don't forget to chmod erlang.cookie to 600 if using the docker volume hack.

  • 2
    In version 3.9.12 in status it says: "RABBITMQ_ERLANG_COOKIE env variable support is deprecated and will be REMOVED in a future version. Use the $HOME/.erlang.cookie file or the --erlang-cookie switch instead."
    – bkomac
    Jan 18, 2022 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .