Error rabbitmq container using docker-compose. Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces

Hi today I ran into a problem, were rabbitmq won’t deploy anymore in my preview environment. The problem occured when I deleted the preview environment and relaunched it again with Github Actions.

This is my docker-compose.yml:

version: '3.8'

services:
  mongodb:    
    image: mongo:latest
    networks:
    - services-network
    ports:
      - 27017:27017    
    restart: always    
    volumes:      
    - mongodb_data_container:/data/db
  mysqldb:
    image: 'mysql/mysql-server:8.0'
    ports:
    - '3307:3306'
    environment:
        MYSQL_ROOT_PASSWORD: ${MYSQL_DB_PASSWORD:-********}
        MYSQL_ROOT_HOST: ${MYSQL_DB_HOST:-%}
        MYSQL_DATABASE: ${MYSQL_DB_NAME:-cqrsdb}
        MYSQL_USER: ${MYSQL_DB_USERNAME:-root}
        MYSQL_PASSWORD: ${MYSQL_DB_PASSWORD:-********}
        MYSQL_ALLOW_EMPTY_PASSWORD: 1
    volumes: 
    - 'sail-mysql:/var/lib/mysql'
    healthcheck:
        test: ['CMD', "mysqladmin", "ping", "-p${MYSQL_DB_PASSWORD:-********}"]
        retries: 3
        timeout: 5s
    networks:
    - services-network
  rabbitmq:
    image: rabbitmq:management
    container_name: rabbitmq
    hostname: "rabbitmq"
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 30s
      retries: 10
    networks:
      - services-network
    ports:
      - "7003:7003"
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME:-admin}
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-password}
  auth_service:
    image: flex/auth-service
    container_name: auth-service
    hostname: auth_service
    restart: on-failure
    networks:
      - services-network
    depends_on:
      rabbitmq:
        condition: service_healthy
    ports:
      - "5002:80"
    build:
      context: .
      dockerfile: Auth.Microservice/Dockerfile
    environment:
      ASPNETCORE_ENVIRONMENT: ${APP_ENV:-Development}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY:-******************************}
      CLIENT_SECRET: ${AZURE_CLIENT_SECRET}
      DOMAIN: ${DOMAIN:-http://localhost:5000}
      RABBITMQ_USERNAME: ${RABBITMQ_USERNAME:-admin}
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-password}
  #reservation_service:
  #  image: flex/reservation-service
  #  container_name: reservation-service
  #  hostname: reservation_service
  #  restart: on-failure
  #  networks:
  #    - services-network
  #  depends_on:
  #    rabbitmq:
  #      condition: service_healthy
  #    mysqldb:
  #      condition: service_healthy
  #  ports:
  #    - "5001:80"
  #  build:
  #    context: .
  #    dockerfile: Reservation.Microservice/Dockerfile
  #  environment:
  #    ASPNETCORE_ENVIRONMENT: ${APP_ENV:-Development} 
  #    RABBITMQ_USERNAME: ${RABBITMQ_USERNAME:-admin}
  #    RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-password}
  admin_service:
    image: flex/admin-service
    container_name: admin-service
    hostname: admin_service
    restart: on-failure
    networks:
      - services-network
    depends_on:
      rabbitmq:
        condition: service_healthy
    ports:
      - "5003:80"
    build:
      context: .
      dockerfile: Admin.Microservice/Dockerfile
    environment:
      ASPNETCORE_ENVIRONMENT: ${APP_ENV:-Development} 
      RABBITMQ_USERNAME: ${RABBITMQ_USERNAME:-admin}
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-password}
      # For local development check if mongo db uses credentials
      # If username and password is used:
      # MONGO_DB_CONNECTION_STRING: ${MONGO_DB_CONNECTION_STRING:-mongodb://{mongoDbUsername}:{mongoDbPassword}@host.docker.internal:27017}
      MONGO_DB_CONNECTION_STRING: ${MONGO_DB_CONNECTION_STRING:-mongodb://host.docker.internal:27017}
  cqrs_service:
    image: flex/cqrs-service
    container_name: cqrs-service
    hostname: cqrs_service
    restart: on-failure
    networks:
      - services-network
    depends_on:
      rabbitmq:
        condition: service_healthy
      mysqldb:
        condition: service_healthy
    ports:
      - "5004:80"
    build:
      context: .
      dockerfile: CQRS.Microservice/Dockerfile
    environment:
      ASPNETCORE_ENVIRONMENT: ${APP_ENV:-Development} 
      RABBITMQ_USERNAME: ${RABBITMQ_USERNAME:-admin}
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-password}
      MYSQL_HOST: ${MYSQL_DB_HOST:-host.docker.internal}
      MYSQL_DATABASE: ${MYSQL_DB_NAME:-cqrsdb}
      # For local development check if mysql uses credentials
      MYSQL_USER: ${MYSQL_DB_USERNAME:-root}
      MYSQL_PASSWORD: ${MYSQL_DB_PASSWORD:-********}
  api_gateway:
    image: flex/api-gateway
    container_name: api-gateway
    hostname: api_gateway
    restart: on-failure
    networks:
      - services-network
    links: 
      - auth_service
      #- reservation_service
      - admin_service
    depends_on:
      prometheus:
        condition: service_healthy
      grafana:
        condition: service_healthy
    ports:
      - "5000:80"
    build:
      context: .
      dockerfile: Gateway.API/Dockerfile
    environment:
      ASPNETCORE_ENVIRONMENT: ${APP_ENV:-Development}
      ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:8081,http://127.0.0.1:8081}
  grafana:
    container_name: grafana_grafprom
    image: grafana/grafana:master
    ports:
      - "3000:3000"
    volumes:
        - ./grafana/provisioning/datasources/:/etc/grafana/provisioning/datasources/
        - ./grafana/provisioning/dashboards/:/etc/grafana/provisioning/dashboards/
    depends_on:
        prometheus:
            condition: service_healthy
    healthcheck:
        test: wget -q --tries=1 -O- http://host.docker.internal:3000/
        interval: 3s
        timeout: 3s
        retries: 10
        start_period: 10s   
    networks:
      - services-network
  prometheus:
    image: prom/prometheus
    container_name: prometheus_grafprom
    restart: always
    ports:
      - 9090:9090
    volumes:
      - ./prometheus/:/etc/prometheus/
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    healthcheck:
        test: wget -q --tries=1 -O- http://host.docker.internal:9090/
        interval: 3s
        timeout: 3s
        retries: 10
        start_period: 10s
    networks:
      - services-network
networks:
  services-network:
volumes:
    sail-mysql:
        driver: local
    mongodb_data_container:

And this is the error that I get when I am deploying the rabbitmq container in the okteto preview environment:

2023-04-06 11:24:43.00 UTCrabbitmq-6685f7f8fd-qxwtj[pod-event]Successfully pulled image "rabbitmq:management" in 434.394002ms
2023-04-06 11:24:57.00 UTCrabbitmq-6685f7f8fd-qxwtj[pod-event]Readiness probe failed: 
2023-04-06 11:25:03.00 UTCrabbitmq-6685f7f8fd-qxwtj[pod-event]Back-off restarting failed container
2023-04-06 11:25:17.00 UTCrabbitmq-6685f7f8fd-qxwtj[pod-event]Successfully pulled image "rabbitmq:management" in 397.008119ms
2023-04-06 11:26:00.00 UTCrabbitmq-6685f7f8fd-qxwtj[pod-event]Successfully pulled image "rabbitmq:management" in 421.006966ms
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.661713+00:00 [error] <0.146.0> Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> supervisor: {local,net_sup}
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> errorContext: start_error
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> reason: {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> [{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {auth,init,1,[{file,"auth.erl"},{line,165}]},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {proc_lib,init_p_do_apply,3,
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> [{file,"proc_lib.erl"},{line,240}]}]}
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> offender: [{pid,undefined},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {id,auth},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {mfargs,{auth,start_link,[]}},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {restart_type,permanent},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {significant,false},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {shutdown,2000},
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> {child_type,worker}]
2023-04-06 12:03:46.75 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752706+00:00 [error] <0.144.0> 
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> crasher:
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> initial call: auth:init/1
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> pid: <0.146.0>
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> registered_name: []
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> exception error: "Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces"
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> in function auth:init_no_setcookie/0 (auth.erl, line 313)
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> in call from auth:init/1 (auth.erl, line 165)
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> in call from gen_server:init_it/2 (gen_server.erl, line 851)
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> in call from gen_server:init_it/6 (gen_server.erl, line 814)
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> ancestors: [net_sup,kernel_sup,<0.47.0>]
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> message_queue_len: 0
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> messages: []
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> links: [<0.144.0>]
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> dictionary: []
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> trap_exit: true
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> status: running
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> heap_size: 1598
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> stack_size: 28
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> reductions: 2261
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> neighbours:
2023-04-06 12:03:46.77 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.752468+00:00 [error] <0.146.0> 
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> 
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> BOOT FAILED
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> ===========
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> Exception during startup:
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> 
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> error:{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_21@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,supervisor,[erl_distribution]}}}}
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> 
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> rabbit_prelaunch_dist:duplicate_node_check/1, line 80
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> rabbit_prelaunch_dist:setup/1, line 23
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> rabbit_prelaunch:do_run/0, line 115
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> rabbit_prelaunch:run_prelaunch_first_phase/0, line 32
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> supervisor:do_start_child_i/3, line 414
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> supervisor:do_start_child/2, line 400
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> supervisor:-start_children/2-fun-0-/3, line 384
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> supervisor:children_map/4, line 1250
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:46.780976+00:00 [error] <0.132.0> 
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmqBOOT FAILED
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq===========
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmqException during startup:
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmqerror:{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_21@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,supervisor,[erl_distribution]}}}}
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    rabbit_prelaunch_dist:duplicate_node_check/1, line 80
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    rabbit_prelaunch_dist:setup/1, line 23
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    rabbit_prelaunch:do_run/0, line 115
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    rabbit_prelaunch:run_prelaunch_first_phase/0, line 32
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    supervisor:do_start_child_i/3, line 414
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    supervisor:do_start_child/2, line 400
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    supervisor:-start_children/2-fun-0-/3, line 384
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq    supervisor:children_map/4, line 1250
2023-04-06 12:03:46.78 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> supervisor: {local,rabbit_prelaunch_sup}
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> errorContext: start_error
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> reason: {badmatch,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {error,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {{shutdown,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {failed_to_start_child,auth,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [{auth,init_no_setcookie,0,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [{file,"auth.erl"},{line,313}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {auth,init,1,[{file,"auth.erl"},{line,165}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {gen_server,init_it,2,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [{file,"gen_server.erl"},{line,851}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {gen_server,init_it,6,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [{file,"gen_server.erl"},{line,814}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {proc_lib,init_p_do_apply,3,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [{file,"proc_lib.erl"},{line,240}]}]}}},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {child,undefined,net_sup_dynamic,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {erl_distribution,start_link,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [#{clean_halt => false,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> name => rabbit_prelaunch_21@localhost,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> name_domain => shortnames,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> net_tickintensity => 4,net_ticktime => 60,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> supervisor => net_sup_dynamic}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> permanent,false,1000,supervisor,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> [erl_distribution]}}}}
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> offender: [{pid,undefined},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {id,prelaunch},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {mfargs,{rabbit_prelaunch,run_prelaunch_first_phase,[]}},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {restart_type,transient},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {significant,false},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {shutdown,5000},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> {child_type,worker}]
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.827795+00:00 [error] <0.132.0> 
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> crasher:
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> initial call: application_master:init/4
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> pid: <0.130.0>
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> registered_name: []
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> exception exit: {{shutdown,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {failed_to_start_child,prelaunch,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {badmatch,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {error,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {{shutdown,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {failed_to_start_child,auth,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [{auth,init_no_setcookie,0,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [{file,"auth.erl"},{line,313}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {auth,init,1,[{file,"auth.erl"},{line,165}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {gen_server,init_it,2,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [{file,"gen_server.erl"},{line,851}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {gen_server,init_it,6,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [{file,"gen_server.erl"},{line,814}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {proc_lib,init_p_do_apply,3,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [{file,"proc_lib.erl"},{line,240}]}]}}},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {child,undefined,net_sup_dynamic,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {erl_distribution,start_link,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [#{clean_halt => false,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> name => rabbit_prelaunch_21@localhost,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> name_domain => shortnames,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> net_tickintensity => 4,net_ticktime => 60,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> supervisor => net_sup_dynamic}]},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> permanent,false,1000,supervisor,
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> [erl_distribution]}}}}}},
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> {rabbit_prelaunch_app,start,[normal,[]]}}
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> in function application_master:init/4 (application_master.erl, line 142)
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> ancestors: [<0.129.0>]
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> message_queue_len: 1
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> messages: [{'EXIT',<0.131.0>,normal}]
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> links: [<0.129.0>,<0.44.0>]
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> dictionary: []
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> trap_exit: true
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> status: running
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> heap_size: 610
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> stack_size: 28
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> reductions: 188
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> neighbours:
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.828543+00:00 [error] <0.130.0> 
2023-04-06 12:03:47.83 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq2023-04-06 12:03:47.829586+00:00 [notice] <0.44.0> Application rabbitmq_prelaunch exited with reason: {{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_21@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,100... <truncated>
2023-04-06 12:03:49.35 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq{"Kernel pid terminated",application_controller,"{application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{\"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces\",[{auth,init_no_setcookie,0,[{file,\"auth.erl\"},{line,313}]},{auth,init,1,[{file,\"auth.erl\"},{line,165}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,851}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,240}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_21@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,fals... <truncated>
2023-04-06 12:03:49.35 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmqKernel pid terminated (application_controller) ({application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_21@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,superv... <truncated>
2023-04-06 12:03:49.35 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmq
2023-04-06 12:03:49.42 UTCrabbitmq-6685f7f8fd-qxwtjrabbitmqCrash dump is being written to: erl_crash.dump...

Could somebody please give me direction where the problem is in my docker-compose file? Or if the problem is even in the docker-compose file, because I did not change anything.

Hi @iomilovanderpas,

It seems this issue is a low level race condition from the rabbitmq base image:

From the answers to that GitHub link, try setting the runtime user to the UID of the rabbitmq user:

services:
  rabbitmq:
    user: 999