Cloud and Container Basics

In Docker, which of the following correctly describes named volumes and bind mounts, used to keep data written by a container?

  1. AA volume is stored in an area managed by Docker and a bind mount in a host directory you specify, and both remain after the container is removed
  2. BData in a named volume remains after the container is removed, but data in a bind mount also disappears from the host directory when the container is removed
  3. CBoth are created as part of the container's writable layer, so removing the container with docker rm also deletes the data
Show answer and explanation

Answer: A. A volume is stored in an area managed by Docker and a bind mount in a host directory you specify, and both remain after the container is removed

Data written to a container's writable layer disappears when the container is removed, so data that must be kept is placed outside the container. A named volume is created in an area managed by Docker and remains until it is explicitly deleted, for example with docker volume rm. A bind mount makes any host directory visible inside the container, and the data simply remains as files on the host. Bind mounts are common during development, when source code edited on the host should take effect immediately, and volumes are common for data whose management is best left to Docker, such as database data.

  • A. Correct. The locations differ, but both are outside the container, so the data remains.
  • B. The data of a bind mount is the files in the host directory themselves, so removing the container does not delete them.
  • C. Both are outside the container's writable layer, so they remain after the container is removed.
Practice this topic Back to topic

Books on Cloud and Container Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Cloud and Container Basics questions

  1. An image is pulled by specifying registry.example.com/team/web:1.4. Which of the following correctly gives the meaning of each part of this reference?
  2. scratch is an empty image that contains no files. Which of the following correctly describes what the final image built with the multi-stage Dockerfile above contains?
  3. In Kubernetes, which of the following is the smallest unit that is deployed and managed, grouping one or more containers that share the same IP address and volumes?
  4. In Kubernetes, a Deployment with replicas: 3 is running three Pods. Which of the following correctly describes what happens when one of these Pods is deleted with kubectl delete pod?
  5. In a Kubernetes Deployment, the container image in the Pod template is changed to a new version. Which of the following correctly describes what happens with the default update strategy (RollingUpdate)?