Recently started learning docker from course. In docker image lecture I saw dock . . .

Totoro:
Recently started learning docker from course.
In docker image lecture I saw dockerfile is pulling Ubuntu image. Why is linux image required? Isn’t the point of docker to run it independent of OS?
Also I have seen dockerfiles of nodejs app but they don’t contain any “FROM ubuntu” or any other linux flavour, why is that?

Matthew Robinson:
The application that you want to run inside the container almost certainly requires various libraries and other supporting files. The easiest way to provide these files is to base your custom image on an existing image.

The base image you choose depends on the requirements of the application you want to run. The Ubuntu image is one that contains a lot of the files that might be required. There are other smaller images like Alpine that have less files in them which means a smaller image.

Some applications don’t require any supporting files (statically linked binaries) so they can be built using the scratch base image (basically an empty image).

I don’t know the nodejs image but there is a good chance that it was built on top of another image (like ubuntu or debian).

Matthew Robinson:
I just had a look at the offical node image and it is based on a Debian image

Totoro:
so how is docker image different from a VM which runs on say alpine linux? Why use docker in this case?

Matthew Robinson:
Docker containers share the Linux kernel with the host system and if carefully crafted can contain the bare minimum files (libraries etc) that the application requires.

Matthew Robinson:
The container is running as part of the host operating system but is sand-boxed from other processes on the host

Matthew Robinson:
A VM is an entire self contained operating system that is sharing the hosts CPU. VMs require a lot more resources (CPU, memory, storage) than a container

Matthew Robinson:
Even the container images like Ubuntu have considerably fewer packages installed than a standard installation of the same Linux distribution

Totoro:
thanks, things are more clear now. It will eventually be more clear with time and consistent learning I think