Docker with 2x -p commands?

Viewed 12

Why does this docker run command have 2x -p commands?

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.10-management

According to docker run --help, -p "Publishes a container's port(s) to a the host". Does that mean there are 2 ports exposed?

Opening the container from docker desktop in a browser, it opens in http://localhost:15672/.

Attempting to navigate to http://localhost:5672/ shows a sad chrome tab and the below in the console.

enter image description here enter image description here

Is that port 5672 maybe used for something else besides a browser?

1 Answers

Yes, passing -p multiple times does exactly that - expose multiple ports.

Port 15672 is the management interface, which does serve HTTP traffic, and as such can be accessed from your browser. Port 5672, on the other hand, is the main port used by RabbitMQ for communicating with clients through the AMQP protocol. Browsers do not "speak" AMQP, and as such trying to access it with a browser will give you that error.

Related