Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

docker - 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.

question from:https://stackoverflow.com/questions/65833825/why-do-we-need-to-have-an-alpine-or-ubuntu-base-image-in-the-dockerfile

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...