Docker Config Reference (docker port)

We go over using the docker port command and give many examples of it!

Docker Config Reference (docker port)
docker port examples
docker port mycontainer

This command retrieves and displays all port mappings for the specified container "mycontainer". It lists each internal port bound to an external host port or IP address, providing a comprehensive overview of how the container's services are exposed. This is particularly useful for verifying network configurations in development environments, ensuring that expected ports are accessible without requiring additional inspection tools.

docker port mycontainer 80

This command queries the port mapping specifically for the internal port 80 of "mycontainer". It outputs the corresponding external host port and IP, facilitating targeted checks for web services like HTTP. Such precision aids in troubleshooting connectivity issues or confirming load balancer integrations in multi-container setups.

docker port mycontainer 80/tcp

By specifying the protocol (TCP), this command displays the mapping for port 80 over TCP in "mycontainer". It ensures protocol-specific exposure details are retrieved, which is essential for applications requiring distinct handling of TCP versus UDP traffic, thereby supporting secure and efficient network planning.

docker port --format "table {{.PrivatePort}} {{.Type}} {{.IP}} {{.PublicPort}}" mycontainer

This command formats the output as a table with private port, type, IP, and public port for "mycontainer". It improves readability for human operators, making it suitable for documentation or reporting in team-based environments.

docker port mycontainer | awk '{print $3}'

This command retrieves mappings for "mycontainer" and uses awk to extract the third field (typically the external mapping). It provides customized parsing for specific data extraction in scripts.

This command queries the mapping for RabbitMQ port 5672 in "rabbitmqcontainer". It supports message queue connectivity verification in asynchronous systems.

docker port mycontainer 465/tcp

This command displays the TCP mapping for SMTPS port 465 in "mycontainer". It ensures secure email transmission configurations are correctly exposed.

docker port elasticcontainer 9200

This command retrieves the port mapping for Elasticsearch port 9200 in "elasticcontainer". It aids in search engine access confirmation for data indexing applications.

docker port mycontainer 110/tcp

This command lists the TCP mapping for POP3 port 110 in "mycontainer". It supports email retrieval service exposure checks.

docker port kibacontainer 5601

This command queries the mapping for Kibana port 5601 in "kibacontainer". It facilitates visualization tool accessibility in logging stacks.

docker port mycontainer 143/tcp

This command displays the TCP mapping for IMAP port 143 in "mycontainer". It ensures email client connectivity for message access.

docker port prometheuscontainer 9090

This command retrieves the port mapping for Prometheus port 9090 in "prometheuscontainer". It supports monitoring system exposure verification.

docker port mycontainer 995/tcp

This command lists the TCP mapping for POP3S port 995 in "mycontainer". It confirms secure email retrieval configurations.

docker port --help

This command displays the help documentation for the docker port command, including usage syntax, options, and descriptions. It serves as a reference for users seeking clarification on command functionality without executing mappings.