I am new to docker and trying to understand the concept of base image.
Let's say I have a hello-world docker app on windows machine with ubuntu as base image in Dockerfile.
Now to run this hello-world application, Is docker going to install the whole ubuntu to run the application?
If not then how ubuntu base image will be used here and How will Docker container facilitate the commutation between ubuntu based application and windows OS?
You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.
Docker has been able to run Linux containers on Windows desktop since it was first released in 2016 (before Hyper-V isolation or Linux containers on Windows were available) using a LinuxKit based virtual machine running on Hyper-V.
Docker image containers can also run natively on Linux and Windows. However, Windows images can run only on Windows hosts and Linux images can run on Linux hosts and Windows hosts (using a Hyper-V Linux VM, so far), where host means a server or a VM.
Docker images can support multiple platforms, which means that a single image may contain variants for different architectures, and sometimes for different operating systems, such as Windows. When running an image with multi-platform support, docker automatically selects the image that matches your OS and architecture.
Now to run this hello-world application, Is docker going to install the whole ubuntu to run the application?
No, the ubuntu image used is not "the whole ubuntu". It is a trimed-down version, without the all X11 graphic layer. Still 180 MB though: see "Docker Base Image OS Size Comparison".
These days, you would rather use an Alpine image (5 MB): see "Docker Official Images are Moving to Alpine Linux"
Regarding the hello-world application specifically, there is no Ubuntu or Alpine involved. Just 1.8 KB of C machine-code, which makes only direct calls to the Linux kernel of the host.
That Linux host is used by docker container through system calls: see "What is meant by shared kernel in Docker?"
On Windows, said Linux host was provided by VirtualBox VM running a boot2docker VM, built from a TinyCore distro.
With the more recent "Docker for Windows", that same VM is run through the Hyper-V Windows feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With