Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why docker has ability to run different linux distribution? [closed]

Tags:

linux

docker

We can use docker to pull different images. And these images are different linux distribution. But no matter which linux distro docker is running on, docker can run these different linux distribution just like in a virtual machine.

I know docker uses aufs to control different read-write access level. So it can reuse some file on the host machine. But how can docker run apt-get in a container when my host runs arch linux? Does the image contain the apt-get binary? But different linux distribution have different libs and software version. Even the configuration file are different.How can docker "run" ubuntu in a arch linux?

like image 709
atupal Avatar asked Aug 22 '14 09:08

atupal


People also ask

How can Docker run on different Linux distribution?

We can use docker to pull different images. And these images are different linux distribution. But no matter which linux distro docker is running on, docker can run these different linux distribution just like in a virtual machine. I know docker uses aufs to control different read-write access level.

How does Docker run different operating systems?

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.

Is Docker limited to Linux based containers?

Differences. And here's what makes Docker on Windows different: Docker supports only certain versions of Windows (namely, Windows Server 2016 and Windows 10). In contrast, Docker can run on any type of modern Linux-based operating system.


2 Answers

Because the kernel is the same.

The common point of all linux distributions, and why they are called linux, is because they all use the linux kernel.

Containers share the same kernel as the host, that's why you can run an Arch image on a Ubuntu host.

Here's an overview of Linux.

The kernel is a part of the operating system that handles communication with the hardware. It's the lowest level of the operating system. Here is a list of the main functions of the kernel:

  • memory management
  • network management
  • device driver
  • file management
  • process management

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 the reason you can't use Windows inside a container: it's not using the same syscall).

like image 50
Regan Avatar answered Oct 14 '22 15:10

Regan


Yes the images will have to contain apt-get for you to be able to run apt-get. Each image can have different software installed inside it. So you could install an Arch docker image or an ubuntu image for example. You can search for public images using the following command.

docker search <your search term>

so to search for an ubuntu image you could use

docker search ubuntu

I'd recommend following through the docker tutorial and carefully reading all the instructions and links on the left as you go through.

like image 44
Jim Jeffries Avatar answered Oct 14 '22 15:10

Jim Jeffries