rabbitmq docker container .erlang.cookie is not set from RABBITMQ_ERLANG_COOKIE env variable
Solution 1
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
rabbitmq:
image: rabbitmq:3-management
ports:
- "15672:15672"
- "25672:25672"
- "5672:5672"
- "4369:4369"
environment:
- RABBITMQ_ERLANG_COOKIE='takeMyCookies'
hostname: "${HOST}"
Take a look at the cookie value
root@prod-03:/# cat ~/.erlang.cookie
'takeMyCookies'
root@prod-03:/# cat /var/lib/rabbitmq/.erlang.cookie
'takeMyCookies'
Solution 2
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
Solution 3
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"
Related videos on Youtube
![raitisd](https://i.stack.imgur.com/OfKNq.jpg?s=256&g=1)
raitisd
Updated on September 18, 2022Comments
-
raitisd almost 2 years
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 aRABBITMQ_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 icat /var/lib/rabbitmq/.erlang.cookie
I get a different valueAYMNAPKRPCPJVPFYAJZX
.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.
-
Andy Shinn about 7 yearsCan 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. -
raitisd about 7 years@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.
-
-
bkomac over 2 yearsIn 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."