I am creating an image using Dockerfile, and I would like to add users to RabbitMQ right after installation. The problem is that during the build, the hostname of the docker container is different from when I run the resulting image. RabbitMQ is losing this user; due to the changed host name, it is using a different database.
I can change the /etc/hosts and /etc/hostname files from inside the container and it looks like RabbitMQ does not select my changes in the variables RABBITMQ_NODENAME and HOSTNAME .
The only thing I found was to run this before starting the RabbitMQ broker:
echo " NODENAME=rabbit@localhost " >> /etc/rabbitmq/rabbitmq.conf.d/ewos.conf
But then I have to run the docker image with the changed host name all the time.
docker run -h="localhost" image
Any ideas on what can be done? Maybe the solution is to add users to RabbitMQ, not to the assembly, but when the image starts?
source share