I’m trying to run rabbitmq service with following configuration:
version: '3.9'
services:
rabbit-mq:
container_name: rabbitmq
image: rabbitmq:3-management
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
RABBITMQ_DEFAULT_VHOST: 'test'
ports:
- '5672:5672'
- '15672:15672'
networks:
monorepo:
gateway:
container_name: gateway
environment:
- APP_PORT=${GATEWAY_MS_PORT}
build:
context: .
args:
- APP_NAME=monorepo-project
ports:
- ${GATEWAY_MS_PORT}:${GATEWAY_MS_PORT}
networks:
monorepo:
user-microservice:
container_name: user-microservice
environment:
- APP_PORT=${USER_MS_PORT}
build:
context: .
args:
- APP_NAME=user-microservice
ports:
- ${USER_MS_PORT}:${USER_MS_PORT}
networks:
monorepo:
depends_on:
- user-microservice-db
user-microservice-db:
image: mysql:latest
container_name: user-microservice-db
environment:
MYSQL_ROOT_PASSWORD: ${USER_MS_MYSQL_PASSWORD}
MYSQL_DATABASE: ${USER_MS_MYSQL_DATABASE}
ports:
- ${USER_MS_MYSQL_PORT}:${INTERNAL_DB_PORT}
networks:
monorepo:
networks:
monorepo:
However, rabbitmq service give me the following error:
2022-04-03 12:59:28.937375+00:00 [info] <0.1164.0> closing AMQP connection <0.1164.0> (172.31.0.5:37026 -> 172.31.0.3:5672)
2022-04-03 12:59:30.941567+00:00 [info] <0.1171.0> accepting AMQP connection <0.1171.0> (172.31.0.5:37028 -> 172.31.0.3:5672)
2022-04-03 12:59:30.947123+00:00 [error] <0.1171.0> Error on AMQP connection <0.1171.0> (172.31.0.5:37028 -> 172.31.0.3:5672, state: starting):
2022-04-03 12:59:30.947123+00:00 [error] <0.1171.0> PLAIN login refused: user 'guest' - invalid credentials
Without default user and pass it works as expected. I’ve been searching for resolve last couple of days and have tried all suggestions from google.
Also, with my RABBITMQ_DEFAULT_USER
and RABBITMQ_DEFAULT_PASS
I can login into managment plugin without any problem.
My .env file:
#RABBITMQ CONFIG
RABBITMQ_DEFAULT_USER=monorepo
RABBITMQ_DEFAULT_PASS=monorepo
RABBITMQ_PORT=5672
RABBITMQ_URL=rabbitmq
RABBITMQ_QUEUE=users
2
Answers
After 3.8 the environment variables that you are using are no longer supported.
Use something like this in
/etc/rabbitmq/definitions.json
:Then add
./rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro
to your volumes in your docker-compose.yaml.The username and password is
test12
.I don’t know why, but
default_pass
doesn’t appear in /etc/rabbitmq.conf.Solution for me was:
mkdir ./rabbit_config
touch ./rabbit_config/rabbitmq.conf
./rabbit_config/rabbitmq.conf
:docker-compose down
&docker-compose up -d
And
username
,password
became valid credentinals.P.S. On top of that, environment has just started work with no reason