DCA · Question #2
Which one of the following commands will show a list of volumes for a specific container?
The correct answer is B. 'docker container inspect nginx'. To view the volumes associated with a specific container, the docker container inspect command is used to retrieve detailed low-level information about that container.
Question
Which one of the following commands will show a list of volumes for a specific container?
Options
- A'docker container logs nginx --volumes'
- B'docker container inspect nginx'
- C'docker volume inspect nginx'
- D'docker volume logs nginx --containers'
How the community answered
(35 responses)- A6% (2)
- B91% (32)
- C3% (1)
Why each option
To view the volumes associated with a specific container, the `docker container inspect` command is used to retrieve detailed low-level information about that container.
The `docker container logs` command retrieves the standard output and error streams of a container and does not provide information about its attached volumes.
The `docker container inspect <container_name_or_id>` command provides comprehensive low-level details about a container, including its mounted volumes and bind mounts, listed under the 'Mounts' section of its JSON output.
The `docker volume inspect <volume_name>` command displays information about a specific Docker volume, not about which volumes are linked to a particular container.
`docker volume logs` is not a valid Docker command and cannot be used to list volumes for a container.
Concept tested: Inspecting container volume mounts
Source: https://docs.docker.com/engine/reference/commandline/inspect/
Topics
Community Discussion
No community discussion yet for this question.