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?
- ABoth uname -r and /etc/os-release show information about the host kernel and the host distribution
- BBoth uname -r and /etc/os-release show information about the distribution the image is based on and its kernel
- 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.