为什么docker有能力运行不同的linux发行版? [英] Why docker has ability to run different linux distribution?

查看:503
本文介绍了为什么docker有能力运行不同的linux发行版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用docker拉动不同的图像。而这些图像是不同的linux发行版。
但是无论哪个linux发行版Docker都可以运行,docker可以在虚拟机中运行这些不同的linux分发jsut。



我知道docker使用 aufs 来控制不同的读写访问级别。所以它可以在主机上重用一些文件。但是当我在一个 arch linux 中运行docker时,docker可以如何在容器中运行 apt-get 命令? imagegs是否包含 apt-get 二进制文件?但不同的linux发行版有不同的libs和软件版本。即使是配置文件也不同,Docker可以在一个arch linux中运行一个ubuntu?

解决方案

因为内核是相同的。



所有linux发行版的共同点,以及为什么被称为linux,是因为它们都使用linux内核。



容器与主机共享相同的内核,这就是为什么您可以在Ubuntu主机上运行Arch映像。



以下是Linux的概述。 / p>

内核是处理与硬件通信的操作系统的一部分。这是操作系统的最低级别。以下是内核的主要功能列表:




  • 内存管理

  • 网络管理

  • 设备驱动程序

  • 文件管理

  • 进程管理



所以当你使用容器你只能访问主机的内核,因为它是与硬件通信的唯一部分,只要你的操作系统使用好的 syscall ,您可以在容器内运行任何linux分发。 (这是您不能在容器内使用Windows的原因:它不使用相同的 syscall )。


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

I know docker use aufs to control diffrent read-write access level. So it can reuse some file on host machine. But how can docker run a apt-get command in a container when I run docker in a arch linux ? Is the imagegs contain the apt-get binary? But different linux distribution has different libs and software version. Even the configuration file are differnt.How docker can "run" a ubuntu in a arch linux?

解决方案

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).

这篇关于为什么docker有能力运行不同的linux发行版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆