Cloud and Container Basics

On a Linux host, Docker is used to start a container from an image based on a different distribution from the host, and uname -r (which shows the kernel release) and cat /etc/os-release (which shows information about the distribution) are run inside it. Which of the following correctly describes the results?

  1. ABoth uname -r and /etc/os-release show information about the host kernel and the host distribution
  2. BBoth uname -r and /etc/os-release show information about the distribution the image is based on and its kernel
  3. Cuname -r shows the host kernel, and /etc/os-release shows the distribution of the image
Show answer and explanation

Answer: C. uname -r shows the host kernel, and /etc/os-release shows the distribution of the image

A container shares the host kernel, so uname -r, which asks the kernel, shows the release of the host kernel even inside the container. /etc/os-release, on the other hand, is a file, so it is read from the file system the container sees, that is, from the image, and it shows the name of the image's distribution. An image contains no kernel, only user-space files such as commands and libraries. For this reason, a program that relies on a feature the host kernel lacks will not work inside a container either.

  • A. /etc/os-release is a file in the container's file system, so the contents of the image are read.
  • B. An image contains no kernel. The host kernel is shared, so uname -r shows the host release.
  • C. Correct. The kernel is shared with the host, while the files seen are those of the image.
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. Which of the following correctly describes the relationship between a container image and a container?
  2. 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)?
  3. 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?
  4. 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?
  5. 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?