在Docker容器中运行不同的Linux OS? [英] Run Different Linux OS in Docker Container?

查看:282
本文介绍了在Docker容器中运行不同的Linux OS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在尝试学习Docker,让我感到困惑的是,在Docker容器中实际上如何运行与主机操作系统不同的Linux。

Have been trying to learn Docker and one thing that puzzles me is how a different flavour of Linux (to the host OS) actually runs in the Docker container.

如果我们假设我的Docker主机正在运行RedHat,并且我是从Ubuntu映像启动一个容器,那么是否满足以下条件?

If we assume my Docker host is running RedHat and I start a container from an Ubuntu image then are the following true?:


  • 从逻辑上讲,如果Ubuntu映像占用空间约为550MB,那么Doc​​ker Daemon会实际下载(从映像注册表中)550MB的Ubuntu映像以创建容器吗?

  • Ubuntu实例是否正在运行在容器中的本质与我手动下载并安装相同版本的容器没有什么不同?

我知道Docker容器共享与主机操作系统使用的内核相同,而Docker的基本要点之一是它使用基础操作系统提高了容器的效率。因此,对于启动从与主机不同的Linux版本创建的Container时实际发生的事情,我有些困惑。

I'm aware that the Docker container shares the same kernel used by the host OS and that one of the fundamental points of Docker was its efficiency gains of the container using the underlying OS. So Im a bit confused about what actually happens when you start a Container created from a different Linux version than the host.

推荐答案

I认为上一篇文章可能会帮助您更多地了解它- Docker容器隔离,它是否关心底层Linux操作系统?

I think this previous post may help you understand it a little more - Docker container isolation, does it care about underlying Linux OS?.

问题的症结在于,如果主机操作系统是RedHat然后是RedHat内核,无论您在Docker容器中运行的任何Linux构建都将使用它,即。在您的示例中为Ubuntu。

The crux of the matter is that if the Host OS is RedHat then it is the RedHat kernel which will be used by whatever build of Linux you run in your Docker container ie. Ubuntu in your example.

这归结为了解Linux OS 与Linux之间的区别 图片 。您不会在Docker容器中运行完整的Ubuntu操作系统,而是运行Ubuntu的映像。

This comes down to understanding what the difference is between a Linux OS and a Linux Image. You will not be running a full Ubuntu OS inside the Docker Container but an image of Ubuntu.

出于您的问题,请考虑:-

For the purpose of your question think:-

OS =内核+文件系统/库

Image =文件系统/库

OS = kernel + filesystem/libraries
Image = filesystem/libraries

在Docker容器中运行的Ubuntu映像只是Ubuntu文件系统/库-它不包含Ubuntu内核。这部分解释了您从Docker容器获得的效率,该容器利用了底层Host的内核(除其他外)。

The Ubuntu image running inside your Docker container is just the Ubuntu filesystem/libraries - it will not contain the Ubuntu kernel. This partly explains the efficiencies you get from a Docker container which is leveraging the Kernel (among other things) of the underlying Host.

这篇关于在Docker容器中运行不同的Linux OS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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