Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Docker DCA Exam - Topic 3 Question 130 Discussion

Can this set of commands identify the published port(s) for a container?Solution. 'docker port inspect", docker container inspect"
B) No
A) Yes

Docker DCA Exam - Topic 3 Question 130 Discussion

Actual exam question for Docker's DCA exam
Question #: 130
Topic #: 3
[All DCA Questions]

Can this set of commands identify the published port(s) for a container?

Solution. 'docker port inspect", docker container inspect"

Show Suggested Answer Hide Answer
Suggested Answer: B

The set of commandsdocker port inspectanddocker container inspectwill not identify the published port(s) for a container. The reason is that there is no such command asdocker port inspect.The correct command to inspect the port mappings of a container isdocker port1.The commanddocker container inspectcan also show the port mappings of a container, but it will display a lot of other information as well, so it isnot as concise asdocker port2. To identify the published port(s) for a container, you can use either of these commands:

docker port CONTAINERwill list all the port mappings of the container1.

docker port CONTAINER PRIVATE_PORTwill list only the port mapping of the specified private port of the container1.

docker container inspect --format=' { {.NetworkSettings.Ports}}' CONTAINERwill list only the port mappings of the container in a JSON format23.

For example, if you have a container namedwebthat publishes port 80 to port 8080 on the host, you can use any of these commands to identify the published port:

$ docker port web

80/tcp -> 0.0.0.0:8080

$ docker port web 80

0.0.0.0:8080

$ docker container inspect --format=' { {.NetworkSettings.Ports}}'web

map[80/tcp:[map[HostIp:0.0.0.0 HostPort:8080]]]

:

docker port

docker container inspect

How can I grab exposed port from inspecting docker container?


Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel