Trooper
Trooper

Reputation: 145

Does docker use virtualization solution when running in linux machines?

When using Docker for Windows, the containers run side-by-side in a hyper-v linux VM on Windows. So when launching a container in ubuntu, is any virtualization solution like hyper-v needed or are the containers just running as processes inside ubuntu?

Source for my first statement - How docker desktop runs linux containers on Windows machine

Upvotes: 0

Views: 514

Answers (2)

atline
atline

Reputation: 31664

First, why hyper-v?

The reason for docker on windows using hyper-v VM just because: for a linux container, it had to share the linux kernel of host. But on windows, we do not have linux kernel, so docker set a hyper-v VM for you, then let your container to share the kernel.

Second, why not VM on linux?

But on linux, the host already has a linux kernel, so container can share this kernel without using any VM.

In fact, from next diagram you can see when you start a new container, it will auto new a process containerd-shim, it will run as a process which you can use ps aux | grep docker to see it on linux host.

enter image description here

And, finally, what is container?

Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container, then every process in container will run in a separated namespace. See official docementation.

Upvotes: 1

d4nyll
d4nyll

Reputation: 12667

"Containers" is a concept that combines (primarily) two features implemented in the Linux kernel - control groups and namespaces. You need the VM on top of Windows because Windows does not implement these two features.

Therefore, when you run containers natively on Linux, each container will simply run as separate processes constrained by control groups and namespaces.

Upvotes: 1

Related Questions