I run a RabbitMQ service and Celery in a Docker container for my server. Workers are celery instances which connect to the server via RabbitMQ.
I set up and run RabbitMQ like this:
sudo service rabbitmq-server start
rabbitmqctl add_user bunny password
rabbitmqctl add_vhost bunny_host
rabbitmqctl set_permissions -p bunny_host bunny ".*" ".*" ".*"
This has a problem: if a worker tries to connect between the service being started and the bunny user being created and given permissions, then the worker's celery instance will terminate.
I tried adding this to the Dockerfile for my server to add the user before "live" startup:
RUN sudo service rabbitmq-server start && \
rabbitmqctl add_user bunny password && \
rabbitmqctl add_vhost bunny_host && \
rabbitmqctl set_permissions -p bunny_host bunny ".*" ".*" ".*" && \
sudo service rabbitmq-server stop
But when I restarted the rabbitmq-server service within the container, the user bunny did not exist.
(If I try to use rabbitmqctl to add a user when the service is not running, it errors out.)
Any help would be much appreciated.