I have seen a docker run command line as following:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
This command launch the image rabbitmq:3-management With the option --it, it runs in the interactive mode, so we can execute commands inside the container while it is still running. With the option --name, it allow me to assign the rabbitmq name to my container.
What i dont understand is the -p option, why it is twice ?
I know that the only way to access the process is from inside of it. To allow external connections to the container, you have to open (publish) specific ports.
So it is working like: docker run -p 8080:80 [image_name]
.
so it this command i to map TCP port 80 in the container to port 8080 on the Docker host.
So my question is why it is like this
-p 5672:5672 -p 15672:15672 rabbitmq:3-management
Why i have -p twice ?
Why i have the same port 5672:5672 and 15672:15672
?
Thanks