Docker Port Command
# Docker port Command
[Docker Command Encyclopaedia](#)
* * *
`docker port` CommandUsed to display port mapping information of a container, i.e., how ports inside the container are mapped to ports on the host.
`docker port` CommandVery useful for understanding how containers interact with the host network.
### Syntax
docker port CONTAINER [PRIVATE_PORT]
* **`CONTAINER`**: The name or ID of the container to query for port mappings.
* **`PRIVATE_PORT`** (optional): The port number inside the container.
* **`PROTO`** (optional): Protocol type (`tcp` or `udp`οΌοΌThe default is `tcp`γ
View all port mappings of a container:
docker port my_container
Show all port mapping information for the container named my_container.
View mappings for a specific port:
docker port my_container 80
Show which host port the port 80 inside the container named my_container is mapped to.
View mappings for a specific port and protocol:
docker port my_container 80/tcp
Show which host port the TCP port 80 inside the container named my_container is mapped to.
### Examples
Start a container and map ports:
docker run -d -p 8080:80 --name my_container nginx
ThisCommandSet my_container Port 80 of the container is mapped to port 8080 on the host machine.
View port mappings of a container:
docker port my_container
Output:
80/tcp -> 0.0.0.0
YouTip