Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need to have an Alpine or Ubuntu Base Image in the Dockerfile?

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.

like image 323
user3473520 Avatar asked Sep 02 '25 15:09

user3473520


1 Answers

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/

like image 144
Daniel Hornik Avatar answered Sep 05 '25 13:09

Daniel Hornik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!