DCA practice question 5 of 25
Can this set of commands identify the published port(s) for a container? Solution: docker container inspect', 'docker port'
Full set: 191 questionsYes, this set of commands can identify the published ports for a container. The docker port command is a direct and concise tool specifically for this purpose; it lists all port mappings in a simple format (e.g., 80/tcp -> 0.0.0.0:8080). The docker container inspect command provides a comprehensive JSON output of the container's configuration and runtime state. Within this output, the NetworkSettings.Ports key contains a detailed object listing all port bindings, including the host IP and port that a container port is mapped to. Both commands effectively provide the required information.
B. This is incorrect because both docker port and docker container inspect are valid and standard commands for retrieving a container's port mapping information.
1. Docker Documentation, "docker port," Reference > CLI. The official documentation states its purpose is to "List port mappings or a specific mapping for the container."
2. Docker Documentation, "docker container inspect," Reference > CLI. The documentation shows that the command's output includes a NetworkSettings object, which contains a Ports map detailing the host-to-container port bindings.
Keep practicing
Take the free DCA practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DCA practice questions
- Question 1Does this command create a swarm service that only listens on port 53 using the UDP proto…
- Question 2Will this command ensure that overlay traffic between service tasks is encrypted? Solutio…
- Question 4Does this describe the role of Control Groups (cgroups) when used with a Docker container…
- Question 6Will this command mount the host's '/data' directory to the ubuntu container in read-only…
- Question 7A company's security policy specifies that development and production containers must run…
- Question 9Will this action upgrade Docker Engine CE to Docker Engine EE? Solution: Uninstall 'docke…
