Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use rabbitmqctl to connect to the rabbitmqserver in the docker container?

I've used docker to start my rabbitmqserver. How can I use rabbitmqctl to connect to the rabbitmqserver in the docker container?

Port 5672 has been exposed and map to the 5672 port of my host. But I still get the following error:

Status of node rabbit@m2 ...
Error: unable to connect to node rabbit@m2: nodedown
like image 520
waitingkuo Avatar asked Dec 03 '13 07:12

waitingkuo


People also ask

How do I use Rabbitmqctl with docker?

Open a terminal, navigate to your rabbitmq-go folder and run docker-compose up . This command will pull the rabbitmq:3-management-alpine image, create the container rabbitmq and start the service and webUI. You should see something like this: Once you see this, open your browser and head over to http://localhost:15672.

How do I access RabbitMQ from docker?

If you open your Docker engine, you will see the RbbitMQ container set and running. If you open http://localhost:15672/ on a browser, you will be able to access the management Ui, and now you can log in using the docker-compose set username and password. And now you can see the RabbitMQ instance is up and running.

How do I connect to a remote service from a docker container?

Install Docker on your SSH host. You do not need to install Docker locally. Follow the quick start for the Remote - SSH extension to connect to a host and open a folder there. Use the Remote-Containers: Reopen in Container command from the Command Palette (F1, Ctrl+Shift+P).

How do I connect a docker container?

Use docker attach to attach your terminal's standard input, output, and error (or any combination of the three) to a running container using the container's ID or name. This allows you to view its ongoing output or to control it interactively, as though the commands were running directly in your terminal.


2 Answers

Assuming your container is called rabbitmq and is running:

docker exec rabbitmq rabbitmqctl start_app
like image 124
Jonathan Avatar answered Sep 23 '22 00:09

Jonathan


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.

like image 26
sysoff Avatar answered Sep 22 '22 00:09

sysoff