Cloud and Container Basics

Inside a container started from an image, the configuration file /etc/app.conf, which is part of the image, is modified. Which of the following correctly describes what happens with Docker's usual storage mechanism (such as overlay2)?

  1. AThe file is copied into the container's writable layer and then modified, so the image and other containers are not affected
  2. BThe file in the image layer is modified directly, so other containers started from the same image also see the new contents
  3. CImage layers are read-only, so files contained in the image cannot be modified, and the write fails with an error
Show answer and explanation

Answer: A. The file is copied into the container's writable layer and then modified, so the image and other containers are not affected

A container's file system presents the read-only image layers with a writable layer for that container stacked on top, as a single tree. The first time a file in a lower layer is modified, it is copied into the writable layer, and from then on the copy is used (copy-on-write). The image layers therefore stay unchanged, and other containers sharing the same image are not affected. Because the first copy of a large file takes time, data that is written frequently, such as database data, is placed in a volume.

  • A. Correct. On the first write, the file is copied into the writable layer.
  • B. Image layers are read-only and shared by several containers, so they are not modified directly.
  • C. The write does not fail; it happens after the file is copied into the writable layer.
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. To unpack a 500 MB archive, data.tar.gz, an image was built with the Dockerfile above. Although the archive was deleted in the same RUN after unpacking, the image remained larger by the size of the archive. Which of the following is the most appropriate pair of reason and remedy?
  2. There are five images, each of which stacks its own 30 MB layer on the same base image (120 MB). Layer compression and the size of metadata are ignored. Which of the following is the disk space used by the images when all five are pulled to one server?
  3. For the Dockerfile above, which of the following correctly pairs the command executed when the image is built with docker build and the command executed when a container is started with docker run?
  4. An image named pinger, built from the Dockerfile above, is started with docker run pinger example.com. Which of the following is the command executed in the container?
  5. A container is started with the command above from the image nginx, a web server that listens on port 80. The host's IP address is 192.0.2.10, and there are no restrictions such as a firewall. Which of the following is the URL to use to reach this web server from a browser on another PC on the same network?