'RabbitMQ fails to startup when I start a docker container

I have installed RabbitMQ inside a docker container on Ubuntu 20.04 using the following steps: https://computingforgeeks.com/how-to-install-latest-rabbitmq-server-on-ubuntu-linux/

It works as expected and I can use it in a sample python program.

After installation I exit the container and save it to a new docker image using:

docker commit *my_container_id* *my_new_container_name*
docker save -o image_with_rabbitmq.tar *my_new_container_name*

I then load this new image and run it like so:

docker load -i image_with_rabbitmq.tar
docker run --rm --gpus all -it *my_image_id*

But now I find that I cannot start or use rabbitmq anymore. I get the following error:

service rabbitmq-server status
Distribution failed: {{:shutdown, {:failed_to_start_child, :net_kernel, {:EXIT, :nodistribution}}}, {:child, :undefined, :net_sup_dynamic, {:erl_distribution, :start_link, [[:"rabbitmqcli-184-rabbit@231b2003671d", :shortnames, 15000], false, :net_sup_dynamic]}, :permanent, false, 1000, :supervisor, [:erl_distribution]}}

Here is the startup log message:

cat /var/log/rabbitmq/startup_err 

BOOT FAILED
===========
Exception during startup:

error:{badmatch,{error,{{shutdown,{failed_to_start_child,net_kernel,   {'EXIT',nodistribution}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[[rabbit_prelaunch_9642@localhost,shortnames],false,net_sup_dynamic]},permanent,false,1000,supervisor,[erl_distribution]}}}}

rabbit_prelaunch_dist:duplicate_node_check/1, line 78
rabbit_prelaunch_dist:setup/1, line 23
rabbit_prelaunch:do_run/0, line 115
rabbit_prelaunch:run_prelaunch_first_phase/0, line 32
supervisor:do_start_child_i/3, line 414
supervisor:do_start_child/2, line 400
supervisor:-start_children/2-fun-0-/3, line 384
supervisor:children_map/4, line 1250

Kernel pid terminated (application_controller) ({application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[[rabbit_prelaunch_9642@localhost,shortnames],false,net_sup_dynamic]},permanent,false,1000,supervisor,[erl_distribution]}}}}}},{rabbit_prelaunch_app,start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done

How can I ensure this starts up properly when my container starts?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source