Cloud and Container Basics
Which of the following correctly describes the relationship between a container image and a container?
- AWhen a container is stopped, the changes made inside it are automatically written back to the image, overwriting the original image
- BAn image is a read-only template, and several containers, each with its own writable layer, can be started from one image
- COnly one container at a time can be started from an image, and starting a second one requires copying the image under another name first
Show answer and explanation
Answer: B. An image is a read-only template, and several containers, each with its own writable layer, can be started from one image
An image is a read-only template that bundles the files and settings needed to run an application, and a container is a unit of execution created from an image. When a container is created, a writable layer of its own is stacked on top of the image's layers. Many containers can therefore be started from one image, and changes in one container affect neither the other containers nor the image. To keep a change as part of an image, the usual approach is to edit the Dockerfile and rebuild the image.
- A. Changes made in a container stay only in that container's writable layer; the image does not change automatically.
- B. Correct. The image is shared, and each container gets its own writable layer.
- C. Any number of containers can be started from the same image. There is no need to copy the image.