Docker 查看镜像分层信息

Docker About 3,389 words

history

docker history 

输出:--no-trunc参数可以查看完整CREATED BY信息。如果控制台影响查看信息,可以使用>重新定到文本。

root@local:~# docker history myapp2
IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
9e7291127fb2   25 hours ago   ENTRYPOINT ["java" "-jar" "/app/app.jar"]       0B        buildkit.dockerfile.v0
<missing>      25 hours ago   ENV JAVA_OPTS=-Xms10m -Xmx20m                   0B        buildkit.dockerfile.v0
<missing>      25 hours ago   COPY target/property-env-0.0.1-SNAPSHOT.jar …   17.5MB    buildkit.dockerfile.v0
<missing>      25 hours ago   WORKDIR /app                                    0B        buildkit.dockerfile.v0
<missing>      7 months ago   /bin/sh -c #(nop)  CMD ["jshell"]               0B
<missing>      7 months ago   /bin/sh -c set -eux;   arch="$(objdump="$(co…   343MB
<missing>      7 months ago   /bin/sh -c #(nop)  ENV JAVA_VERSION=11.0.13     0B
<missing>      7 months ago   /bin/sh -c #(nop)  ENV LANG=C.UTF-8             0B
<missing>      7 months ago   /bin/sh -c #(nop)  ENV PATH=/usr/java/openjd…   0B
<missing>      7 months ago   /bin/sh -c #(nop)  ENV JAVA_HOME=/usr/java/o…   0B
<missing>      7 months ago   /bin/sh -c set -eux;  microdnf install   gzi…   39.6MB
<missing>      7 months ago   /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>      7 months ago   /bin/sh -c #(nop) ADD file:3223e5829b65b376c…   110MB

inspect

可以查看构建信息,以及Layers各层的IMAGE ID镜像ID,可以配合docker images --no-trunc获取各层镜像。

docker inspect

输出

root@local:~# docker inspect myapp2
[
    {
        "Id": "sha256:9e7291127fb234de0148f3d297e00151ab1bc6d607de01b1894b5957a6c079a8",
        "RepoTags": [
            "myapp2:latest"
        ],
        "Parent": "",
        "Config": {
            "Env": [
                "PATH=/usr/java/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "JAVA_HOME=/usr/java/openjdk-11",
                "LANG=C.UTF-8",
                "JAVA_VERSION=11.0.13",
                "JAVA_OPTS=-Xms10m -Xmx20m"
            ],
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "java",
                "-jar",
                "/app/app.jar"
            ]
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 510109019,
        "VirtualSize": 510109019,
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:54b5e2b53cf2ad50dd4869a7e7814bf62eb5484735bc39aa7aea08af3bfc9c89",
                "sha256:eb109653b21acea9702512341ec0e30a111204976e809eb946b6bfc2e86c6da9",
                "sha256:3ece5814f91033bc41d8d689dd036c18c9b50b4cc65a3830093688b5fe6577fe",
                "sha256:6eb01a5af180f2651918ecf39c28d279227fb334467a90acb8d1cedb192f661a",
                "sha256:c8e0954c7f630dca5f8299e3b3d02555e420605d1361b8a243756b85e2a9cd7d"
            ]
        }
    }
]

images

使用--no-trunc参数,不截断IMAGE ID,查看镜像ID

docker images --no-trunc

输出

root@local:~# docker images myapp2 --no-trunc
REPOSITORY   TAG       IMAGE ID                                                                  CREATED        SIZE
myapp2       latest    sha256:9e7291127fb234de0148f3d297e00151ab1bc6d607de01b1894b5957a6c079a8   25 hours ago   510MB
Views: 2,886 · Posted: 2022-12-05

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh