Check The published Ports Of A Running Docker Container
1. List All The Mapped Ports Of TheContainer
First, create an HTTPD server with a docker container.
#docker run -itd --name cont_1 -p 8080:80 httpd
Now list the ports of the docker container “cont_1”.
#docker port cont_1 Output: 80/tcp -> 0.0.0.0:8080 80/tcp -> :::8080
2. List Randomly Allocated Ports
#docker run -itd --name cont_2 -P httpd
#docker port cont_2 Output: 80/tcp -> 0.0.0.0:49153 80/tcp -> :::49153
3. Check Any Specific Port OfA Docker Container
#docker port cont_2 80/tcp Output: 0.0.0.0:49153 :::49153
How to Map Ports in Docker?
In docker, all the application in the container runs on particular ports when you run a container. If you want to access the particular application with the help of a port number you need to map the port number of the container with the port number of the docker host.
Contact Us