【问题标题】:Where does Docker image initial filesystem come from?Docker 镜像初始文件系统从何而来?
【发布时间】:2017-12-22 09:41:27
【问题描述】:

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

  • .travis.yml

    <...>
    script:
      - docker build --rm -t quay.io/pypa/manylinux1_$PLATFORM:$TRAVIS_COMMIT -f docker/Dockerfile-$PLATFORM docker/
    
  • docker/Dockerfile-&lt;arch&gt;:

    COPY build_scripts /build_scripts
    RUN bash build_scripts/build.sh
    
  • docker/build_scripts/build.sh:

    <a bunch of variables>
    sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
    <...>
    

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

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

【问题讨论】:

  • 我不确定我是否理解你的问题,/etc/yum 已经在基本 centos 映像中docker run -it centos ls /etc/yum
  • 好吧,我在代码中没有看到任何对“基本 CentOS 映像”(更何况,CentOS 5 映像)的引用。它来自哪里,Docker 如何知道它应该使用它?

标签: docker docker-build python-manylinux


【解决方案1】:

查看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 镜像构建在 Dockerfile 中定义的层结构中。通过在 Dockerfile 中使用 FROM syntax,镜像构建在彼此之上。

在这种情况下,图像基于centos:5.11 图像。语法在docker tag | Docker Documentation 进行了解释(见图)。在这种情况下,没有目录地址,这意味着它是从默认的Docker Hub registry 中的centos entry 检索到的,即带有5.11 tag 的那个。

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

【讨论】:

  • 好的,您能否添加一个指向解释centos:5.11 语法的文档的链接(docker run 帮助不这样做)?一定是从某个“默认”的在线图片目录中获取的——我可以浏览哪个目录?
  • @ivan_pozdeev 更新了答案,使其更清晰。
  • 添加了一些缺失的位。现在完美了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-16
  • 1970-01-01
  • 2016-01-13
  • 2020-12-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多