I am trying to dockerize my Java application which tries to connect to a Rabbitmq server. I have passed the Rabbitmq Url via docker env variable and readig the same url using
System.getenv("RABBITMQ_URL")
, but it came out to be null. Is there anything wrong with the way I am reading the docker env variable ? Here is my Docker create command :
docker service create --name xxx --env
RABBITMQ_URL=amqp://rabbitmq:xxxx --network msgq --with-registry-auth
${imageName}
解决方案
This is weird but, restarting the docker container just worked fine for me. Turns out , i have to restart the container when ever I update the network connection using "--network". Thanks