首页 > 解决方案 > How does Docker handle different kernel versions?

问题描述

Let's say that I make an image for an OS that uses a kernel of version 10. What behavior does Docker exhibit if I run a container for that image on a host OS running a kernel of version 9? What about version 11?

Does the backward compatibility of the versions matter? I'm asking out of curiosity because the documentation only talks about "minimum Linux kernel version", etc. This sounds like it doesn't matter what kernel version the host is running beyond that minimum. Is this true? Are there caveats?

标签: docker

解决方案


假设我为使用版本 10 内核的操作系统制作映像。

我认为这有点误解,除非您谈论的是依赖于 Docker 映像中较新内核功能的特定软件,这应该很少见。一般来说,Docker 镜像只是一个自定义文件/目录结构,通过一个或多个指令分层组装,FROM并带有一些元数据,例如要打开哪些端口或在容器启动时执行哪个文件。这就是它的全部。Docker 的基本原理很像经典的chroot 监狱,只是更现代一点,上面加了一些糖果。RUNDockerfiles

如果我在运行版本 9 内核的主机操作系统上运行该映像的容器,Docker 会表现出什么行为?版本 11 怎么样?

如果内核可以运行 Docker 守护程序,它应该能够运行任何映像。

有警告吗?

如上所述,包含依赖前沿内核功能的软件的 Docker 映像将无法在没有这些功能的内核上运行,这不足为奇。Docker 不会阻止您在较旧的内核上运行这样的映像,因为它根本不关心映像内部的内容,也不知道用于创建映像的内核是什么。

我唯一能想到的另一件事是手动编译软件,并针对英特尔或 AMD 等特定 cpu 进行积极优化。这样的图像将在具有不同 cpu 的主机上失败。


推荐阅读