在Docker容器中运行不同的Linux OS?

编程入门 行业动态 更新时间:2024-10-23 12:26:39
本文介绍了在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?

本文发布于:2023-11-15 02:57:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1590531.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   Docker   OS   Linux

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!