Since many people still have this problem (including me), I did this:
When creating, copy RabbitMQ database_dir to / var / lib / rabbitmq / mnesia / rabbit \ @ $ (hostname) in / root (everything in / root remains in memory) after setting up all users.
At run time, copy the database directory from / root to / var / lib / rabbitmq / mnesia.
Only drawbacks: changes made to the database in RabbitMQ will be reset at runtime. I have not found another way to do this with docker-compose.
Configure.sh (as the RUN command in the Docker file):
echo "NODENAME=rabbit@message-bus" > /etc/rabbitmq/rabbitmq-env.conf echo "127.0.0.1 message-bus" >> /etc/hosts #prevents error that 'message-bus' node doesnt exist (this doesnt persist in /etc/hosts) rabbitmqctl add user ... #etc rabbitmqctl stop mkdir /root/rabbitmq_database cp -R /var/lib/rabbitmq/mnesia/rabbit\@message-bus/* /root/rabbitmq_database
Runtime.sh (as an entry point to the Docker file):
Thijs B.
source share