Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only

2,002 views
Skip to first unread message

Sami Salim Khan

unread,
May 15, 2023, 7:52:23 AM5/15/23
to rabbitmq-users
Hi all,

i am using Rabbit-MQ as a service in a docker container via docker-compose.yml.

Here is the snippet:
version: "3.6"

services:
  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      - RABBITMQ_DEFAULT_USER=user
      - RABBITMQ_DEFAULT_PASS=password
    volumes:
      - ./docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
      - ./docker-conf/rabbitmq/log/:/var/log/rabbitmq
    networks:
      - local

networks:
  local:

volumes:
  postgres_data:
    driver: local

When running the docker-compose up command, a linux container is being created and the  rabbitmq:3-management-alpine image is downloaded and imported as image. However, after a few seconds i always get the error message "Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only" and teh service is stopped. Even a manual start stops it imediately.

After searching in the internet and also here in this group, i tried to solve the problem by adding the following line to the service configuration:

command: sh -c "chown supervisor:supervisor /var/lib/rabbitmq/.erlang.cookie && chmod 600 /var/lib/rabbitmq/.erlang.cookie"

This causes the service to stop imediately too and shows no log at all!

I am using Docker Desktop for Windows to check the Docker container.

Does anyone have the same problem and have you got a functioning solution for it? Please let me know. Thank you very much in advance.

BR
Sami

Gavin M. Roy

unread,
May 15, 2023, 9:38:01 PM5/15/23
to rabbitm...@googlegroups.com
Check to see what user rabbitmq-server is running on in that docker image you're using and make sure that the .erlang cookie file is owned by the same user and that it's 0600. In Docker the user is specified as the USER directive in the Dockerfile. You might be able to figure out easier by running the docker image with an entrypoint of /bin/sh and then see who you're running as.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/01e8384d-d97f-4ffd-b88b-5a884cb8eb45n%40googlegroups.com.

Sami Salim Khan

unread,
May 24, 2023, 9:35:13 AM5/24/23
to rabbitmq-users
Hi Gavin,

i tried to get to know the rabbitmq-server user but i could not fetch the user info with the entrypoint of /bin/sh in any log. Can you please give me detailled step instructions so that i can follow them? Thanks.

BR Sami
Reply all
Reply to author
Forward
0 new messages