QuestionQ29

702.1 Application Container Management

What occurs when the following command is run twice consecutively?

docker run -tid -v data:/data debian bash

  • A The second command invocation fails with an error stating that the volume data is already associated with a running container.
  • B The container resulting from the second invocation can only read the content of /data/ and can not change it.
  • C The original content of the container image data is available in both containers, although changes stay local within each container.
  • D Both containers share the contents of the data volume, have full permissions to alter its content and mutually see their respective changes.
  • E Each container is equipped with its own independent data volume, available at /data/ in the respective container.
Explanation

A named volume can be mounted by multiple containers simultaneously. Docker creates the named volume if it does not exist and reuses it when the same volume name is mounted again. Because no read-only option is supplied, both containers mount data read-write at /data, so each can modify the shared contents and observe the other container’s changes.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!