305-300 · Question #2
What happens when the following command is executed twice in succession? docker run -tid -v data:/data debian bash
The correct answer is C. Both containers share the contents of the data volume, have full permissions to alter its content. The command docker run -tid -v data:/data debian bash creates and runs a new container from the debian image, with an interactive terminal and a detached mode, and mounts a named volume data at /data in the container. If the volume data does not exist, it is created…
Question
Options
- AThe container resulting from the second invocation can only read the content of /data/ and cannot
- BEach container is equipped with its own independent data volume, available at /data/ in the
- CBoth containers share the contents of the data volume, have full permissions to alter its content
- DThe original content of the container image data is available in both containers, although changes
- EThe second command invocation fails with an error stating that the volume data is already
How the community answered
(37 responses)- A8% (3)
- B3% (1)
- C70% (26)
- D16% (6)
- E3% (1)
Explanation
The command docker run -tid -v data:/data debian bash creates and runs a new container from the debian image, with an interactive terminal and a detached mode, and mounts a named volume data at /data in the container. If the volume data does not exist, it is created automatically. If the command is executed twice in succession, two containers are created and run, each with its own terminal and process ID, but they share the same volume data. This means that both containers can access, modify, and see the contents of the data volume, and any changes made by one container are reflected in the other container. Therefore, the statement C is true and the correct answer. The statements A, B, D, and E are false and incorrect, as they do not describe the behavior of the command or the volume correctly.
Topics
Community Discussion
No community discussion yet for this question.