The set of commands docker container inspect and docker port can identify the published port(s) for a container. The docker container inspect command returns low-level information about a container, including its network settings and port bindings1. The docker port command lists port mappings or a specific mapping for the container2. Both commands can show which host port is mapped to which container port, and the protocol used. For example, docker container inspect -f '{{.NetworkSettings.Ports}}' container_name will show the port bindings for the container_name3. Similarly, docker port container_name will show the port mappings for the container_name. References:
docker container inspect
docker port
How to Expose and Publish Ports in Docker
[How to obtain the published ports from within a docker container?]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit