Docker 图像初始文件系统来自哪里?

Where does Docker image initial filesystem come from?

我正在 https://github.com/pypa/manylinux 查看 manylinux1 股票图像构建脚本,特别是调用链:

脚本假定基本的 CentOS 5 文件系统(例如 /etc/yum)已经存在。 它来自哪里?

我没有看到任何对库存图片的引用,也没有看到任何类似从某处下载或使用安装 ISO 的内容。代码库中的任何地方都没有 /etc

查看manylinux镜像的Dockerfile,可以看出它是基于centos:5.11

FROM centos:5.11
MAINTAINER The ManyLinux project
...

/etc/yum文件夹已经是centos镜像的一部分,可以通过运行验证:docker run -it centos:5.11 ls /etc/yum

更新:

Docker 图像构建在 Docker 文件中定义的层结构中。通过使用 Docker 文件中的 FROM syntax,图像彼此叠加。

在这种情况下,图像基于centos:5.11图像。 docker tag | Docker Documentation (go figure). In this case, there's no directory address, which means it's retrieved from centos entry in the default Docker Hub registry, the one with the 5.11 tag.

中解释了语法

CentOS 的 Dockerfile 非常简单。它只是将具有基本 CentOS 文件结构的 tarball 扩展为 scratch(空)docker 图像。此压缩包 centos-7-docker.tar.xz 在最新版本的情况下,包含 /etc/yum 文件夹等。