dockerdocker-composerabbitmqdocker-desktoprabbitmqctl

How to pass erlang.cookie in "docker run" after RABBITMQ_ERLANG_COOKIE got depricated


I want to start three RabbitMQ containers that will be joined together in a cluster. I want to keep it simple and not define complex Dockerfiles with specific volumes. This is what I am doing right now:

docker network create rabbits
docker run -d --rm --net rabbits --hostname rabbit-1 --name rabbit-1 -p 8081:15672 -e RABBITMQ_ERLANG_COOKIE=ASDF rabbitmq:3.8-management
docker run -d --rm --net rabbits --hostname rabbit-2 --name rabbit-2 -p 8082:15672 -e RABBITMQ_ERLANG_COOKIE=ASDF rabbitmq:3.8-management
docker run -d --rm --net rabbits --hostname rabbit-3 --name rabbit-3 -p 8083:15672 -e RABBITMQ_ERLANG_COOKIE=ASDF rabbitmq:3.8-management

When I then try to tell the nodes to join each other with the following commands, I get an error message:

docker exec -it rabbit-2 rabbitmqctl stop_app
docker exec -it rabbit-2 rabbitmqctl reset
docker exec -it rabbit-2 rabbitmqctl join_cluster rabbit@rabbit-1
docker exec -it rabbit-2 rabbitmqctl start_app
docker exec -it rabbit-2 rabbitmqctl cluster_status

This results in: 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.

However I do not know how to pass this switch. When I add this to the docker run command it does not work. So i thought maybe add this after the join_cluster command, but then the cookie is already set.

How do I need to change the docker run command?


Solution

  • In response to your and other questions about RABBITMQ_ERLANG_COOKIE, I opened this issue:

    https://github.com/rabbitmq/rabbitmq-server/issues/7262

    Currently you should use the environment variable and disregard the warning.

    The best practice is to use docker compose and your own image based off of the official RabbitMQ images:

    https://github.com/lukebakken/docker-rabbitmq-cluster/blob/main/docker-compose.yml

    https://github.com/lukebakken/docker-rabbitmq-cluster/blob/main/rmq/Dockerfile