4

I am new to the Docker world. I want to ask my question by giving an example. Say there is a company that is using a windows OS on their servers. To run a Docker container, they need to have a Linux environment right. Hence, they make use of virtualization technology to create a virtual machine with a Linux environment to run this container. Here, this Linux OS is already acting as a guest OS then why do we need to have/install alpine or Ubuntu as the base image in the docker file? Could you please correct me if my understanding is wrong. Thank you.

  • 2
    To get reproducible builds, the only thing that is used by the Guest (aka a container) is the Linux kernel of the host. The OS (or userland) is not shared. – Tom Jan 21 '21 at 18:49
  • Thank you @Tom for your response. Could you please elaborate a little more on this? Or could you please share any doc where this is specified? – user3473520 Jan 21 '21 at 18:58
  • See https://stackoverflow.com/questions/18786209/what-is-the-relationship-between-the-docker-host-os-and-the-container-base-image – Tom Feb 01 '21 at 19:26

1 Answers1

2

All processes in the Docker Container are isolated.

So By design your Host programs are not available inside the Docker image.

Technically, you do not need Alpine or Ubuntu Linux base image. For example you can use the Scratch image: https://hub.docker.com/_/scratch

Idea of the docker is to provide fully isolated exactly the same environment for application, they do not force to use any base image.

However it's good to use official base image because:

  • You have a lot of tutorials about common distributions
  • You have a lot of preinstalled tools provided with base image.
  • Official images are maintained by community so they are fixing issues for you.

Docker uses layer design, to minimize size of images. More info here: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

Daniel Hornik
  • 1,957
  • 1
  • 14
  • 33