Docker图像文件详细信息

时间:2017-03-11 00:27:58

标签: docker dockerfile

Docker镜像文件是否等同于清单文件,其中包含指向Docker镜像内部的指针 - 也就是不同的图层 - 其中的融合是Docker Image

OR

码头工作者图像文件是一个单片图像,其中包含所有不同的图层,并不一定指向不同的子图层吗?

1 个答案:

答案 0 :(得分:3)

Docker image本质上是一个JSON清单,其中包括SHA256内容校验和对文件系统层的引用。

图层是一组只读的文件系统更改,当与其他图层组合时会生成图像的文件系统。

可以在图像之间共享图层

检查图像

RootFS的{​​{1}}属性列出了图片的图层

docker inspect <image>

您可以从图像的→ docker inspect openjdk:8-jre-alpine [ { "Id": "sha256:d85b17c6762eb3455c7b7ff1930bdde8c911137fe8c7f3c0b5988c66149dc27b", "RepoTags": [ "openjdk:8-jre-alpine" ], "RepoDigests": [ "openjdk@sha256:48ac96e309a748f5778db26be7e45ca0e35931ef58e9b271fe36767a55411728" ], "Parent": "", "Comment": "", "Created": "2016-12-27T18:38:49.797530681Z", "Container": "de5e277bf3e5ac747933bbb8e703382b240fdcdaef9d927faa4e02c1f0cbc35e", "ContainerConfig": { "Hostname": "26ba10d264c2", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", "LANG=C.UTF-8", "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/jre", "JAVA_VERSION=8u111", "JAVA_ALPINE_VERSION=8.111.14-r0" ], "Cmd": [ "/bin/sh", "-c", "set -x \t&& apk add --no-cache \t\topenjdk8-jre=\"$JAVA_ALPINE_VERSION\" \t&& [ \"$JAVA_HOME\" = \"$(docker-java-home)\" ]" ], "ArgsEscaped": true, "Image": "sha256:7bf1d56e53b8a99662fc8314d3860b68f30798646ca0265aeeaa1275f679d314", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": [], "Labels": {} }, "DockerVersion": "1.12.3", "Author": "", "Config": { "Hostname": "26ba10d264c2", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", "LANG=C.UTF-8", "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/jre", "JAVA_VERSION=8u111", "JAVA_ALPINE_VERSION=8.111.14-r0" ], "Cmd": null, "ArgsEscaped": true, "Image": "sha256:7bf1d56e53b8a99662fc8314d3860b68f30798646ca0265aeeaa1275f679d314", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": [], "Labels": {} }, "Architecture": "amd64", "Os": "linux", "Size": 107853459, "VirtualSize": 107853459, "GraphDriver": { "Name": "overlay2", "Data": { "LowerDir": "/var/lib/docker/overlay2/fccc5a703d4022f0fb561a3d0bc6c75da8a99aa1b3291f6be92bf8908e8d5add/diff:/var/lib/docker/overlay2/96ba8cd8b7b44ef284070bd4b98d912fd0bd2b9d6a0d906e661db901408ef38e/diff", "MergedDir": "/var/lib/docker/overlay2/890f1dbb6c802344c58a32e0ee6d2b49dea74418963ab10a0b649ddc50da6127/merged", "UpperDir": "/var/lib/docker/overlay2/890f1dbb6c802344c58a32e0ee6d2b49dea74418963ab10a0b649ddc50da6127/diff", "WorkDir": "/var/lib/docker/overlay2/890f1dbb6c802344c58a32e0ee6d2b49dea74418963ab10a0b649ddc50da6127/work" } }, "RootFS": { "Type": "layers", "Layers": [ "sha256:7cbcbac42c44c6c38559e5df3a494f44987333c8023a40fec48df2fce1fc146b", "sha256:da07d9b32b0090fa42690c204d7b49925b5e65ea770893d02c01ab00d61ff920", "sha256:6f7515f190962a84c9837ad7adb1e684d79fa0d798a57a99fbe090cc0f97f39c" ] } } ] 看到,Dockerfile中有三个命令修改了文件系统。所有其他命令都有助于与图像关联的元数据(使用docker history获取完整输出)

--no-trunc