1

I have recently learned a course of Docker from Udemy but I am having problem understanding what is actually an Image in Docker world is?

What I have learned is that when Docker runs on our system, it itself is a Virtual Machine running Linux Operating System on it. That Linux operating system runs several Containers from Images we provide. A Container has its isolated space on the hard drive, its own Memory and CPU allocated, but unlike a Virtual Machine it is not having a full blown operating system of its own.

But, because I have learned that the Containers share a single operating system, I am confused about the Images we build for running a Container. Because I see that to build a Docker Image, we first of all load a Base Image (Which itself seems to me as an operating system like... FROM Alpine etc..). Then when there is an operating system in the Image itself, why it is said that Containers share the single host Operating System?

teenup
  • 7,459
  • 13
  • 63
  • 122

2 Answers2

4

It is a bit misleading to say that the containers share a single operating system. What they share is the kernel, but not the libraries and support programs that typically come with an OS like cp, or bash.

Henry
  • 42,982
  • 7
  • 68
  • 84
  • So, a base docker image contains just the support programs and the Container share the same kernel. If I just copy a "cp and bash" file from existing Operating system and use it as a base docker image, will it work? – teenup Oct 26 '20 at 06:54
  • I think this question will further explain what I want to ask: https://stackoverflow.com/questions/18274088/how-can-i-make-my-own-base-image-for-docker – teenup Oct 26 '20 at 07:03
  • Thank you, your answer helped me to understand what I wanted to ask, which I didn't know myself. – teenup Oct 26 '20 at 07:04
0

The base image is just a Docker image, which is built with common packages required for all other Docker images. It's always recommended to prepare a base Docker image and to use the same to derive other Docker images. Of course, there is a number of best practices in building a Docker image to make it optimized as much as possible in order to improve the performance and boot time of Docker containers.

When you run the Docker image build, each instruction in the Dockerfile creates one filesystem layer. The filesystem layers are stacked and each filesystem layer contains the delta.

Ashok
  • 3,190
  • 15
  • 31