docker buildのlayerごとに作成されたファイルの場所
docker buildしたときのレイヤーごとに作成されたファイルの在りかを探る。
使用するDockerfile
Dockerfileはdockerの公式サイトのgo buildサンプルを使用する。
# syntax=docker/dockerfile:1 FROM golang:1.16-alpine WORKDIR /app # git clone https://github.com/olliefr/docker-gs-ping COPY go.mod ./ COPY go.sum ./ RUN go mod download COPY *.go ./ RUN go build -o /docker-gs-ping EXPOSE 8080 CMD [ "/docker-gs-ping" ]
build
$ sudo docker build -t docker-gs-ping .
first approach
dockerにはdocker imageの情報を確認するためのinspectコマンドがある。
Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
$ sudo docker inspect docker-gs-ping [ { "Id": "sha256:c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5", "RepoTags": [ "docker-gs-ping:latest" ], (snip) "GraphDriver": { "Data": { "LowerDir": "/var/snap/docker/common/var-lib-docker/overlay2/xv1f7eg4zxl2t2kthiar56d0i/diff:/var/snap/docker/common/var-lib-docker/overlay2/6u481fa9p1yb7ciwgh4dvzw4k/diff:/var/snap/docker/common/var-lib-docker/overlay2/1l2ryygniollff3apm97onnvw/diff:/var/snap/docker/common/var-lib-docker/overlay2/yjihngv30y2xzq0n3p2lh3ynu/diff:/var/snap/docker/common/var-lib-docker/overlay2/lpkdsmfqo8dv4ewz84qromx6q/diff:/var/snap/docker/common/var-lib-docker/overlay2/f9953017f3961de59491869644f97114052ca25d52375c98ea8eea37397d237c/diff:/var/snap/docker/common/var-lib-docker/overlay2/2d4ac34227874536a7bc13774c02c41c1e1116d465b20035bd0a9df17e29f9be/diff:/var/snap/docker/common/var-lib-docker/overlay2/5514a52670c7b15c517e685902fbee69ddcb3247bcb369d6f384546182b99991/diff:/var/snap/docker/common/var-lib-docker/overlay2/4caa9c6e45a305a9718f413b237c2fa2b446a51eaf95199b0ce77f0134ee7f4d/diff:/var/snap/docker/common/var-lib-docker/overlay2/280f9902c753b978c8e8c6065225bae15a8bf37c9945d8aa65ba5e823c19d4f4/diff", "MergedDir": "/var/snap/docker/common/var-lib-docker/overlay2/wic992vhm8oqlitqiqo9az502/merged", "UpperDir": "/var/snap/docker/common/var-lib-docker/overlay2/wic992vhm8oqlitqiqo9az502/diff", "WorkDir": "/var/snap/docker/common/var-lib-docker/overlay2/wic992vhm8oqlitqiqo9az502/work" }, "Name": "overlay2" }, (snip)
これ↓を読むと、
docs.docker.com
ビルド時にレイヤごとに指定したコマンドでファイルが作成される場合は、そのレイヤに対応するディレクタ内にファイルが作成されて、それらのディレクトリを合わせてコンテナになる。
また、「/var/snap/docker/common/var-lib-docker/」のパスは環境によって異なる。
overlayされるディレクトリ
例えば、今回のdocker-gs-pingの場合には
$ sudo docker history docker-gs-ping IMAGE CREATED CREATED BY SIZE COMMENT c529044078e6 2 minutes ago CMD ["/docker-gs-ping"] 0B buildkit.dockerfile.v0 <missing> 2 minutes ago EXPOSE map[8080/tcp:{}] 0B buildkit.dockerfile.v0 <missing> 2 minutes ago RUN /bin/sh -c go build -o /docker-gs-ping #… 21.5MB buildkit.dockerfile.v0 <missing> 2 minutes ago COPY *.go ./ # buildkit 3.55kB buildkit.dockerfile.v0 <missing> 2 minutes ago RUN /bin/sh -c go mod download # buildkit 217MB buildkit.dockerfile.v0 <missing> 2 minutes ago COPY go.sum . # buildkit 29.5kB buildkit.dockerfile.v0 <missing> 2 minutes ago COPY go.mod . # buildkit 1.03kB buildkit.dockerfile.v0 <missing> 2 minutes ago WORKDIR /app 0B buildkit.dockerfile.v0 <missing> 2 days ago /bin/sh -c #(nop) WORKDIR /go 0B <missing> 2 days ago /bin/sh -c mkdir -p "$GOPATH/src" "$GOPATH/b… 0B <missing> 2 days ago /bin/sh -c #(nop) ENV PATH=/go/bin:/usr/loc… 0B <missing> 2 days ago /bin/sh -c #(nop) ENV GOPATH=/go 0B <missing> 2 days ago /bin/sh -c set -eux; apk add --no-cache --v… 296MB <missing> 2 days ago /bin/sh -c #(nop) ENV GOLANG_VERSION=1.16.10 0B <missing> 2 months ago /bin/sh -c #(nop) ENV PATH=/usr/local/go/bi… 0B <missing> 2 months ago /bin/sh -c [ ! -e /etc/nsswitch.conf ] && ec… 17B <missing> 2 months ago /bin/sh -c apk add --no-cache ca-certificates 513kB <missing> 2 months ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B <missing> 2 months ago /bin/sh -c #(nop) ADD file:aad4290d27580cc1a… 5.6MB
ファイルが作成されるのは、DockerfileのコマンドであればADD,COPY,RUN(,WORKDIR)。
その他、今回docker-gs-pingにはファイルが作成されるコマンドは11個あるため、
$ sudo docker inspect docker-gs-ping | grep diff "LowerDir": "/var/snap/docker/common/var-lib-docker/overlay2/xv1f7eg4zxl2t2kthiar56d0i/diff:/var/snap/docker/common/var-lib-docker/overlay2/6u481fa9p1yb7ciwgh4dvzw4k/diff:/var/snap/docker/common/var-lib-docker/overlay2/1l2ryygniollff3apm97onnvw/diff:/var/snap/docker/common/var-lib-docker/overlay2/yjihngv30y2xzq0n3p2lh3ynu/diff:/var/snap/docker/common/var-lib-docker/overlay2/lpkdsmfqo8dv4ewz84qromx6q/diff:/var/snap/docker/common/var-lib-docker/overlay2/f9953017f3961de59491869644f97114052ca25d52375c98ea8eea37397d237c/diff:/var/snap/docker/common/var-lib-docker/overlay2/2d4ac34227874536a7bc13774c02c41c1e1116d465b20035bd0a9df17e29f9be/diff:/var/snap/docker/common/var-lib-docker/overlay2/5514a52670c7b15c517e685902fbee69ddcb3247bcb369d6f384546182b99991/diff:/var/snap/docker/common/var-lib-docker/overlay2/4caa9c6e45a305a9718f413b237c2fa2b446a51eaf95199b0ce77f0134ee7f4d/diff:/var/snap/docker/common/var-lib-docker/overlay2/280f9902c753b978c8e8c6065225bae15a8bf37c9945d8aa65ba5e823c19d4f4/diff", "UpperDir": "/var/snap/docker/common/var-lib-docker/overlay2/wic992vhm8oqlitqiqo9az502/diff", $ sudo docker inspect docker-gs-ping | grep -o diff | wc -l 11
レイヤごとに作成されたファイルを保存するディレクトリは11個ある。
レイヤごとに作成されたディレクトリとhistoryとの対応
これらディレクトリは上位レイヤから順に見ると、
-> RUN /bin/sh -c go build -o /docker-gs-ping
$ ls /var/snap/docker/common/var-lib-docker/overlay2/wic992vhm8oqlitqiqo9az502/diff docker-gs-ping etc root tmp # UpperDir
-> COPY *.go ./
$ ls /var/snap/docker/common/var-lib-docker/overlay2/xv1f7eg4zxl2t2kthiar56d0i/diff app $ ls /var/snap/docker/common/var-lib-docker/overlay2/xv1f7eg4zxl2t2kthiar56d0i/diff/app/ main.go main_test.go
-> RUN /bin/sh -c go mod download
$ ls /var/snap/docker/common/var-lib-docker/overlay2/6u481fa9p1yb7ciwgh4dvzw4k/diff etc go $ ls /var/snap/docker/common/var-lib-docker/overlay2/6u481fa9p1yb7ciwgh4dvzw4k/diff/go/ pkg $ ls /var/snap/docker/common/var-lib-docker/overlay2/6u481fa9p1yb7ciwgh4dvzw4k/diff/go/pkg/ mod sumdb
-> COPY go.sum
$ ls /var/snap/docker/common/var-lib-docker/overlay2/1l2ryygniollff3apm97onnvw/diff app $ ls /var/snap/docker/common/var-lib-docker/overlay2/1l2ryygniollff3apm97onnvw/diff/app/ go.sum
-> COPY go.mod
$ ls /var/snap/docker/common/var-lib-docker/overlay2/yjihngv30y2xzq0n3p2lh3ynu/diff app $ ls /var/snap/docker/common/var-lib-docker/overlay2/yjihngv30y2xzq0n3p2lh3ynu/diff/app/ go.mod
-> WORKDIR /app
$ ls /var/snap/docker/common/var-lib-docker/overlay2/lpkdsmfqo8dv4ewz84qromx6q/diff app
-> /bin/sh -c mkdir -p "$GOPATH/src" "$GOPATH/b…
$ ls /var/snap/docker/common/var-lib-docker/overlay2/f9953017f3961de59491869644f97114052ca25d52375c98ea8eea37397d237c/diff go $ ls /var/snap/docker/common/var-lib-docker/overlay2/f9953017f3961de59491869644f97114052ca25d52375c98ea8eea37397d237c/diff/go/ bin src
-> /bin/sh -c set -eux; apk add --no-cache --v…
$ ls /var/snap/docker/common/var-lib-docker/overlay2/2d4ac34227874536a7bc13774c02c41c1e1116d465b20035bd0a9df17e29f9be/diff bin etc lib root tmp usr var
-> /bin/sh -c [ ! -e /etc/nsswitch.conf ] && ec…
$ ls /var/snap/docker/common/var-lib-docker/overlay2/5514a52670c7b15c517e685902fbee69ddcb3247bcb369d6f384546182b99991/diff etc $ ls /var/snap/docker/common/var-lib-docker/overlay2/5514a52670c7b15c517e685902fbee69ddcb3247bcb369d6f384546182b99991/diff/etc/ nsswitch.conf
-> /bin/sh -c apk add --no-cache ca-certificates
$ ls /var/snap/docker/common/var-lib-docker/overlay2/4caa9c6e45a305a9718f413b237c2fa2b446a51eaf95199b0ce77f0134ee7f4d/diff etc lib usr var
-> /bin/sh -c #(nop) ADD file:aad4290d27580cc1a…
nopだが、alpineのベースイメージが追加される。
$ ls /var/snap/docker/common/var-lib-docker/overlay2/280f9902c753b978c8e8c6065225bae15a8bf37c9945d8aa65ba5e823c19d4f4/diff bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
どのビルド時のコマンドとどのレイヤディレクトリが結びつくのか分かりづらい。
survey
調べていると気になる文言があった。
以下の docker pull コマンドが表しているのは、4つのレイヤに圧縮された Docker イメージを Docker ホスト上にダウンロードしています。 OverlayFS ストレージの使用 — Docker-docs-ja 17.06 ドキュメント(https://docs.docker.jp/engine/userguide/storagedriver/overlayfs-driver.html)
4つのレイヤに圧縮された?
また、 github.comより コンテナイメージは、
. ├── 47bcc53f74dc94b1920f0b34f6036096526296767650f223433fe65c35f149eb.json ├── 5f29f704785248ddb9d06b90a11b5ea36c534865e9035e4022bb2e71d4ecbb9a │ ├── VERSION │ ├── json │ └── layer.tar ├── a65da33792c5187473faa80fa3e1b975acba06712852d1dea860692ccddf3198 │ ├── VERSION │ ├── json │ └── layer.tar ├── manifest.json └── repositories
このようなディレクトリレイアウトで保存される?
docker save
matsuand.github.io これはコンテナイメージのレイヤごとのファイルを確認できそう。
$ sudo docker save docker-gs-ping -o dgp.tar open .docker_temp_527416147: permission denied
docker infoから分かる"Docker Root Dir"外にはアクセス権限が無い。
$ sudo docker info | grep "Docker Root Dir" Docker Root Dir: /var/snap/docker/common/var-lib-docker
tmpは元からある。
$ sudo docker save docker-gs-ping -o /var/snap/docker/common/var-lib-docker/tmp/dgp.tar
そしてその中身は、
$ sudo tar -tf /var/snap/docker/common/var-lib-docker/tmp/dgp.tar 09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e/ 09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e/VERSION 09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e/json 09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e/layer.tar 18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932/ 18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932/VERSION 18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932/json 18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932/layer.tar 1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198/ 1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198/VERSION 1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198/json 1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198/layer.tar 63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43/ 63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43/VERSION 63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43/json 63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43/layer.tar 64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f/ 64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f/VERSION 64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f/json 64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f/layer.tar 69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3/ 69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3/VERSION 69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3/json 69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3/layer.tar 819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b/ 819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b/VERSION 819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b/json 819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b/layer.tar 981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f/ 981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f/VERSION 981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f/json 981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f/layer.tar b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093/ b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093/VERSION b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093/json b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093/layer.tar bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5/ bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5/VERSION bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5/json bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5/layer.tar c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5.json d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106/ d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106/VERSION d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106/json d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106/layer.tar manifest.json repositories
例のディレクトリレイアウト通りである。
例のディレクトリレイアウトの中身
$ sudo tar xf dgp.tar $ ls 09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093 18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932 bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5 1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198 c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5.json 63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43 d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106 64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f dgp.tar 69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3 manifest.json 819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b repositories 981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f
c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5.json
ビルド時のコマンド履歴
$ cat c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5.json | jq { "architecture": "amd64", "config": { "ExposedPorts": { "8080/tcp": {} }, "Env": [ "PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GOLANG_VERSION=1.16.10", "GOPATH=/go" ], "Cmd": [ "/docker-gs-ping" ], "WorkingDir": "/app", "ArgsEscaped": true, "OnBuild": null }, "created": "2021-11-08T01:46:40.287051224+09:00", "history": [ { "created": "2021-08-27T17:19:45.553092363Z", "created_by": "/bin/sh -c #(nop) ADD file:aad4290d27580cc1a094ffaf98c3ca2fc5d699fe695dfb8e6e9fac20f1129450 in / " }, { "created": "2021-08-27T17:19:45.758611523Z", "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", "empty_layer": true }, { "created": "2021-08-30T21:44:05.102152311Z", "created_by": "/bin/sh -c apk add --no-cache ca-certificates" }, { "created": "2021-08-30T21:44:05.978401766Z", "created_by": "/bin/sh -c [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf" }, { "created": "2021-08-30T21:44:06.218718178Z", "created_by": "/bin/sh -c #(nop) ENV PATH=/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "empty_layer": true }, { "created": "2021-11-04T20:26:23.199201425Z", "created_by": "/bin/sh -c #(nop) ENV GOLANG_VERSION=1.16.10", "empty_layer": true }, { "created": "2021-11-04T20:28:05.255820784Z", "created_by": "/bin/sh -c set -eux; \tapk add --no-cache --virtual .fetch-deps gnupg; \tarch=\"$(apk --print-arch)\"; \turl=; \tcase \"$arch\" in \t\t'x86_64') \t\t\texport GOARCH='amd64' GOOS='linux'; \t\t\t;; \t\t'armhf') \t\t\texport GOARCH='arm' GOARM='6' GOOS='linux'; \t\t\t;; \t\t'armv7') \t\t\texport GOARCH='arm' GOARM='7' GOOS='linux'; \t\t\t;; \t\t'aarch64') \t\t\texport GOARCH='arm64' GOOS='linux'; \t\t\t;; \t\t'x86') \t\t\texport GO386='softfloat' GOARCH='386' GOOS='linux'; \t\t\t;; \t\t'ppc64le') \t\t\texport GOARCH='ppc64le' GOOS='linux'; \t\t\t;; \t\t's390x') \t\t\texport GOARCH='s390x' GOOS='linux'; \t\t\t;; \t\t*) echo >&2 \"error: unsupported architecture '$arch' (likely packaging update needed)\"; exit 1 ;; \tesac; \tbuild=; \tif [ -z \"$url\" ]; then \t\tbuild=1; \t\turl='https://dl.google.com/go/go1.16.10.src.tar.gz'; \t\tsha256='a905472011585e403d00d2a41de7ced29b8884309d73482a307f689fd0f320b5'; \tfi; \t\twget -O go.tgz.asc \"$url.asc\"; \twget -O go.tgz \"$url\"; \techo \"$sha256 *go.tgz\" | sha256sum -c -; \t\tGNUPGHOME=\"$(mktemp -d)\"; export GNUPGHOME; \tgpg --batch --keyserver keyserver.ubuntu.com --recv-keys 'EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796'; \tgpg --batch --verify go.tgz.asc go.tgz; \tgpgconf --kill all; \trm -rf \"$GNUPGHOME\" go.tgz.asc; \t\ttar -C /usr/local -xzf go.tgz; \trm go.tgz; \t\tif [ -n \"$build\" ]; then \t\tapk add --no-cache --virtual .build-deps \t\t\tbash \t\t\tgcc \t\t\tgo \t\t\tmusl-dev \t\t; \t\t\t\t( \t\t\tcd /usr/local/go/src; \t\t\texport GOROOT_BOOTSTRAP=\"$(go env GOROOT)\" GOHOSTOS=\"$GOOS\" GOHOSTARCH=\"$GOARCH\"; \t\t\t./make.bash; \t\t); \t\t\t\tapk del --no-network .build-deps; \t\t\t\tgo install std; \t\t\t\trm -rf \t\t\t/usr/local/go/pkg/*/cmd \t\t\t/usr/local/go/pkg/bootstrap \t\t\t/usr/local/go/pkg/obj \t\t\t/usr/local/go/pkg/tool/*/api \t\t\t/usr/local/go/pkg/tool/*/go_bootstrap \t\t\t/usr/local/go/src/cmd/dist/dist \t\t; \tfi; \t\tapk del --no-network .fetch-deps; \t\tgo version" }, { "created": "2021-11-04T20:28:06.148309855Z", "created_by": "/bin/sh -c #(nop) ENV GOPATH=/go", "empty_layer": true }, { "created": "2021-11-04T20:28:06.328709803Z", "created_by": "/bin/sh -c #(nop) ENV PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "empty_layer": true }, { "created": "2021-11-04T20:28:07.131174466Z", "created_by": "/bin/sh -c mkdir -p \"$GOPATH/src\" \"$GOPATH/bin\" && chmod -R 777 \"$GOPATH\"" }, { "created": "2021-11-04T20:28:07.375017775Z", "created_by": "/bin/sh -c #(nop) WORKDIR /go", "empty_layer": true }, { "created": "2021-11-08T01:45:54.657580897+09:00", "created_by": "WORKDIR /app", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:45:56.09940469+09:00", "created_by": "COPY go.mod . # buildkit", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:45:57.510496558+09:00", "created_by": "COPY go.sum . # buildkit", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:46:34.48722682+09:00", "created_by": "RUN /bin/sh -c go mod download # buildkit", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:46:35.787192734+09:00", "created_by": "COPY *.go ./ # buildkit", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:46:40.287051224+09:00", "created_by": "RUN /bin/sh -c go build -o /docker-gs-ping # buildkit", "comment": "buildkit.dockerfile.v0" }, { "created": "2021-11-08T01:46:40.287051224+09:00", "created_by": "EXPOSE map[8080/tcp:{}]", "comment": "buildkit.dockerfile.v0", "empty_layer": true }, { "created": "2021-11-08T01:46:40.287051224+09:00", "created_by": "CMD [\"/docker-gs-ping\"]", "comment": "buildkit.dockerfile.v0", "empty_layer": true } ], "os": "linux", "rootfs": { "type": "layers", "diff_ids": [ "sha256:e2eb06d8af8218cfec8210147357a68b7e13f7c485b991c288c2d01dc228bb68", "sha256:70b223a9dcd76654a2338888932131c343c266a07249a446e2ad40cee2dccfb9", "sha256:eade8b1abd17b25efb4f19b53bb7ade27c2004ac4de8f2bacb471f17e6f28616", "sha256:037763173219da840af35e7abadb586299f276dfa78a87f07e808bce2c204403", "sha256:296905e7082264e3836f2afec90a65d87427b2b870d4c6f74bcb443fd997bd2b", "sha256:1c8f2c78e1d0a4e133fd3a161a7220ce8be0926228acd5d84a3426936fe7176f", "sha256:59b8e08f8da7f6e2f07e2957f701dc983a3195a02464586109e89d322f8786c6", "sha256:9fe90bcd08a2a3e24ee8d70532d42df74dedce587741dd6990f48a80d9524a6a", "sha256:372779383946dbcefd7f9899c5adeaa6651f511854a331ee19c2cb896b1bf21e", "sha256:7873bf2f012102771a540a4a87b8bf1c27c0bb0a23bd53d5c795bfbbbef49ccb", "sha256:7f12fb1bdd8ba8b0df4eb0b45664db70104bb8d991d89540c9c768fc03119312" ] } }
manifest.json
$ cat manifest.json | jq [ { "Config": "c529044078e6a188e7017181b18f1d5e46ee4b39fdc1342c4b76b873a137efe5.json", "RepoTags": [ "docker-gs-ping:latest" ], "Layers": [ "1d63f362c5e879b13b892d0399c38618e126376f645ef7ab9e68e742c5123198/layer.tar", "63902ea0e344b9e93dc3dfd41908d94fd152b1f40909a1b753dc5fdc47f5af43/layer.tar", "981d0ac6df7172fc30ceb55a5f520e855cfd6d49940791c0cb9d5705736d618f/layer.tar", "18cca3c6afb1c8fe7c03cd72db8056517fde1fce5b855778016a2ba5f2a92932/layer.tar", "09c930f2f94714a54559c0943e0403971ec12ce867be035340f14447b053096e/layer.tar", "819c9ad0db091995d042a2cab73afa20cf4c2917d1af6a4315064eb9cda26e1b/layer.tar", "64258c597962ea866cf0f144dad04376f3151529c1f69e7c22d94f729ac81c6f/layer.tar", "b333c8fbbc08796f95b5ceb230300de22959f956a1deeebc5f1e4b5c04528093/layer.tar", "bbf8098c7d37ab725e22bf38202d5dfeb311825a12c904647cf83da1e65b5ef5/layer.tar", "69321ef32863c836992fff72efdb366728a57c6081f6f56bdced970dccbd83e3/layer.tar", "d09f19c590be3164eb0f9d0522f3e392f3d7f331ba2724d08f81e59133a86106/layer.tar" ] } ]
余談
もしかしたら何かの役に立つかもしれない、
docker imageのレイヤごとのファイル名をリスティングするプログラムを作成しました。