Cloud and Container Basics

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?

  1. A150 MB
  2. B270 MB
  3. C750 MB
Show answer and explanation

Answer: B. 270 MB

Image layers are identified by a digest computed from their contents, and an identical layer is stored only once on a server and shared by several images. The 120 MB base layer is stored once, and the five unique layers take 30 MB × 5 = 150 MB, so the total is 120 + 150 = 270 MB. That is 480 MB less than the 750 MB, (120 + 30) × 5, that would be needed without sharing. Using a common base image reduces pull time and disk usage.

  • A. 120 + 30 = 150 MB is the size of a single image. All five unique layers are needed.
  • B. Correct. 120 + 30 × 5 = 270 MB.
  • C. (120 + 30) × 5 = 750 MB is the value if the base layer were not shared.
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. 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?
  2. 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?
  3. 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?
  4. Dockerfile (B) above was made from Dockerfile (A), which had RUN npm ci after COPY . ., by changing the order so that only the dependency files are copied first. npm ci takes 120 seconds, npm run build 30 seconds and COPY . . 2 seconds, and the time of the other instructions is negligible. The image is rebuilt 20 times a day after changing only the source code under src (package.json and package-lock.json are unchanged). When the cache from the previous build can be used, which of the following is how much shorter B is than A in total build time per day?
  5. In Docker, which of the following correctly describes named volumes and bind mounts, used to keep data written by a container?