rabbitmqctl
uses Erlang Distributed Protocol (EDP) to communicate with RabbitMQ. Port 5672 provides AMQP protocol. You can investigate EDP port that your RabbitMQ instance uses:
$ netstat -uptan | grep beam
tcp 0 0 0.0.0.0:55950 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 127.0.0.1:55096 127.0.0.1:4369 ESTABLISHED 31446/beam.smp
tcp6 0 0 :::5672 :::* LISTEN 31446/beam.smp
It means that RabbitMQ:
- connected to EPMD (Erlang Port Mapper Daemon) on 127.0.0.1:4369 to make nodes able to see each other
- waits for incoming EDP connection on port 55950
- waits for AMQP connection on port 5672 and 55672
- waits for incoming HTTP management connection on port 15672
To make rabbitmqctl
able to connect to RabbitMQ you also have to forward port 55950 and allow RabbitMQ instance connect to 127.0.0.1:4369.
It is possible that RabbitMQ EDP port is dinamic, so to make it static you can try to use ERL_EPMD_PORT
variable of Erlang environment variables or use inet_dist_listen_min
and inet_dist_listen_max
of Erlang Kernel configuration options and apply it with RabbitMQ environment variable - export RABBITMQ_CONFIG_FILE="/path/to/my_rabbitmq.conf
my_rabbitmq.conf
[{kernel,[{inet_dist_listen_min, 55950},{inet_dist_listen_min, 55950}]}].
Or you can use RabbitMQ Management Plugin. It is more functional and simple to setup.
-p 55950:55950 -p 5672:5672 -p 15672:15672 -e ERL_EPMD_PORT=55950
when running the docker container, and I haveepmd
running on the host. But still, I can't connect withrabbitmqctl
to the Rabbit instance in the container. – Midis