Symfony 5 and Docker : missing RABBITMQ_DSN env var

I’ve just setup a RabbitMQ Docker container to use with a Symfony 5.2 application. But I’m having troubles with auto-exposed env vars from Docker.

As the RabbitMQ container is up and running fine, I’m waiting for a RABBITMQ_DSN env var automatically set by Symfony.

The weird behaviour is sometimes I do get this env var but sometimes I don’t (on the same request !).

I also get the same behaviour when dumping my env vars (I sware there are no changes between the 2 commands…) :

$ APP_ENV=dev symfony var:export --multiline | grep 'RABBITMQ'
export RABBITMQ_DSN=amqp://guest:[email protected]:49167
export RABBITMQ_HOST=127.0.0.1
export RABBITMQ_MANAGEMENT_HOST=127.0.0.1
export RABBITMQ_MANAGEMENT_IP=127.0.0.1
export RABBITMQ_MANAGEMENT_PORT=49168
export RABBITMQ_MANAGEMENT_SCHEME=http
export RABBITMQ_MANAGEMENT_SERVER=http://127.0.0.1:49168
export RABBITMQ_MANAGEMENT_URL=http://127.0.0.1:49168
export RABBITMQ_PASSWORD=guest
export RABBITMQ_PORT=49167
export RABBITMQ_SCHEME=amqp
export RABBITMQ_SERVER=amqp://127.0.0.1:49167
export RABBITMQ_URL=amqp://guest:[email protected]:49167
export RABBITMQ_USER=guest
export RABBITMQ_USERNAME=guest

$ APP_ENV=dev symfony var:export --multiline | grep 'RABBITMQ'
export RABBITMQ_HOST=127.0.0.1
export RABBITMQ_IP=127.0.0.1
export RABBITMQ_PORT=49168

I’ tried several things :

  • update Docker RabbitMQ image from 3.7 to 3.8
  • clear Symfony cache
  • with auto and manual port mapping (in docker-compose.yaml)
  • updated all my dependencies

But I’m still stuck with this bug… I’m running this app on Windows 10.

Any idea ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *