Coder Perfect

Why does Docker have the ability to run multiple Linux distributions? [closed]

Problem

Docker can be used to pull various images. And these are photos from various Linux distributions. However, regardless of which linux distribution docker is operating on, it can run these various linux distributions just like a virtual machine.

Docker uses aufs to regulate multiple read-write access levels, as far as I’m aware. As a result, it can make use of a file on the host machine. But how can Docker run apt-get in a container on my Arch Linux host? Is the apt-get binary included in the image? Various Linux distributions, on the other hand, have different libraries and software versions. The configuration file is also unique. How does docker manage to “run” Ubuntu on Arch Linux?

Asked by atupal

Solution #1

Because the kernels are identical.

The linux kernel is used by all linux distributions, which is why they are named linux in the first place.

Because containers and hosts share the same kernel, you can run an Arch image on an Ubuntu host.

Here’s a quick rundown of Linux.

The kernel is a component of the operating system that manages hardware communication. It’s the operating system’s most basic level. The following is a list of the kernel’s main functions:

So when you use a container you only have access to the kernel of the host, since it’s the only part that communicates with hardware, as long as your OS uses the good syscall, you are able to run any linux distribution inside your container. (This is why you can’t run Windows within a container because the syscalls aren’t the same.)

Answered by Regan

Solution #2

Yes, apt-get must be included in the images for you to be able to use it. Different software can be placed inside each picture. So, for example, you might install an Arch docker image or an Ubuntu image. You can use the following command to look for public images.

docker search <your search term>

So, if you’re looking for an Ubuntu image, you may use

docker search ubuntu

I recommend going through the Docker tutorial step by step and reading all of the instructions and links on the left.

Answered by Jim Jeffries

Post is based on https://stackoverflow.com/questions/25444099/why-docker-has-ability-to-run-different-linux-distribution