docker pull について確認する

docker pull した時のイメージの構成などを調査した時のメモ。
以下などを参考にさせて頂きました。

[Docker のイメージ/ファイルシステムの形式 (1)](https://qiita.com/Arturias/items/1d29baf346db830a1166)

# 環境

```bash
$docker info
Containers: 30
 Running: 4
 Paused: 0
 Stopped: 26
Images: 10
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.77-80.57.amzn2.x86_64
Operating System: Amazon Linux 2
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 985.7MiB
Name: ip-172-31-30-243.ap-northeast-1.compute.internal
ID: QMDS:ZXZE:7TGX:JJGD:MYCF:6XB4:UVK5:OVX5:5CSQ:HG7K:NP7C:C4PU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
```

# 試す

`docker pull` して `docker save`してみます


```bash
# pull するとレイヤーを並列でダウンロードする
$docker pull


# イメージが存在する
$docker images |grep nginx
nginx                                                              latest              f68d6e55e065        3 days ago          109MB

# tar  に保存
$docker save -o nginx.tar nginx


$tar -xvf nginx.tar
9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/
9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/VERSION
9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/json
9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar
a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/
a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/VERSION
a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/json
a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/layer.tar
d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/
d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/VERSION
d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/json
d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/layer.tar
f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json
manifest.json
tar: manifest.json: implausibly old time stamp 1970-01-01 00:00:00
repositories
tar: repositories: implausibly old time stamp 1970-01-01 00:00:00

# いくつかのファイルが生成される
$ls
9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b
a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0
d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a
f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json
manifest.json
nginx.tar
repositories

# フォルダ構成
$ tree .
.
├── 9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json
├── manifest.json
├── nginx.tar
└── repositories

3 directories, 13 files

```

まずは `mainifest.json` を見てみる

```manifest.json
[
  {
    "Config": "f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json",
    "RepoTags": [
      "nginx:latest"
    ],
    "Layers": [
      "a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/layer.tar",
      "d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/layer.tar",
      "9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar"
    ]
  }
]
```

上記を見るとこのイメージは3つのレイヤーで構成されているように見えます。

`docker image hisoty`で見てみます。

```bash
$docker image history nginx:latest
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
f68d6e55e065        3 days ago          /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B
<missing>           3 days ago          /bin/sh -c #(nop)  STOPSIGNAL SIGTERM           0B
<missing>           3 days ago          /bin/sh -c #(nop)  EXPOSE 80                    0B
<missing>           3 days ago          /bin/sh -c ln -sf /dev/stdout /var/log/nginx…   22B
<missing>           3 days ago          /bin/sh -c set -x     && addgroup --system -…   54.1MB
<missing>           3 days ago          /bin/sh -c #(nop)  ENV PKG_RELEASE=1~stretch    0B
<missing>           3 days ago          /bin/sh -c #(nop)  ENV NJS_VERSION=0.3.3        0B
<missing>           3 days ago          /bin/sh -c #(nop)  ENV NGINX_VERSION=1.17.1     0B
<missing>           3 weeks ago         /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B
<missing>           3 weeks ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B
<missing>           3 weeks ago         /bin/sh -c #(nop) ADD file:5ffb798d64089418e…   55.3MB
```

あれ、3つ以上あるのではと思ったが、サイズを見ると 0B ではないのは3つしかない

以下に書いてあるようにレイヤーが出来るのは `RUN`、`COPY`、`ADD`だけなので上記のようになっていると思われます。

[Minimize the number of layers](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers)

>Only the instructions RUN, COPY, ADD create layers. Other instructions create temporary intermediate images, and do not increase the size of the build.

答え合わせという感じで nginx の Dockerifle を見てみる。

[  docker-nginx/mainline/stretch/Dockerfile  ](https://github.com/nginxinc/docker-nginx/blob/f9fbfcbcb24cb1fd6d207d33e9345d3e6dbb8ff2/mainline/stretch/Dockerfile)

```Dockerfile
FROM debian:stretch-slim

LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"

ENV NGINX_VERSION   1.17.1
ENV NJS_VERSION     0.3.3
ENV PKG_RELEASE     1~stretch

RUN set -x \
# create nginx user/group first, to be consistent throughout docker variants
    && addgroup --system --gid 101 nginx \
    && adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx \
    && apt-get update \
    && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \
    && \
    NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
    found=''; \
    for server in \
        ha.pool.sks-keyservers.net \
        hkp://keyserver.ubuntu.com:80 \
        hkp://p80.pool.sks-keyservers.net:80 \
        pgp.mit.edu \
    ; do \
        echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
        apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
    done; \
    test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
    apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
    && dpkgArch="$(dpkg --print-architecture)" \
    && nginxPackages=" \
        nginx=${NGINX_VERSION}-${PKG_RELEASE} \
        nginx-module-xslt=${NGINX_VERSION}-${PKG_RELEASE} \
        nginx-module-geoip=${NGINX_VERSION}-${PKG_RELEASE} \
        nginx-module-image-filter=${NGINX_VERSION}-${PKG_RELEASE} \
        nginx-module-njs=${NGINX_VERSION}.${NJS_VERSION}-${PKG_RELEASE} \
    " \
    && case "$dpkgArch" in \
        amd64|i386) \
# arches officialy built by upstream
            echo "deb https://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \
            && apt-get update \
            ;; \
        *) \
# we're on an architecture upstream doesn't officially build for
# let's build binaries from the published source packages
            echo "deb-src https://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \
            \
# new directory for storing sources and .deb files
            && tempDir="$(mktemp -d)" \
            && chmod 777 "$tempDir" \
# (777 to ensure APT's "_apt" user can access it too)
            \
# save list of currently-installed packages so build dependencies can be cleanly removed later
            && savedAptMark="$(apt-mark showmanual)" \
            \
# build .deb files from upstream's source packages (which are verified by apt-get)
            && apt-get update \
            && apt-get build-dep -y $nginxPackages \
            && ( \
                cd "$tempDir" \
                && DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
                    apt-get source --compile $nginxPackages \
            ) \
# we don't remove APT lists here because they get re-downloaded and removed later
            \
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
            && apt-mark showmanual | xargs apt-mark auto > /dev/null \
            && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
            \
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
            && ls -lAFh "$tempDir" \
            && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
            && grep '^Package: ' "$tempDir/Packages" \
            && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
#   Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
#   ...
#   E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages  Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
            && apt-get -o Acquire::GzipIndexes=false update \
            ;; \
    esac \
    \
    && apt-get install --no-install-recommends --no-install-suggests -y \
                        $nginxPackages \
                        gettext-base \
    && apt-get remove --purge --auto-remove -y apt-transport-https ca-certificates && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \
    \
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
    && if [ -n "$tempDir" ]; then \
        apt-get purge -y --auto-remove \
        && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
    fi

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
    && ln -sf /dev/stderr /var/log/nginx/error.log

EXPOSE 80

STOPSIGNAL SIGTERM

CMD ["nginx", "-g", "daemon off;"]
```



これを見ると`RUN` は2回実行していた。
一つは「FROM」に対応するベースイメージの情報だとするとレイヤーが3つというのは正しそうです。
`docker image hisotry`は表示内容が上から下にかけて Dockerfile では逆の下から上の内容に合致してそうです。

# 各レイヤーの情報を確認する

各レイヤーの `tar`　を確認する。

```bash
$ ll 9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar
-rw-r--r-- 1 ec2-user ec2-user 3584 Jul  1 21:25 9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar

$ll a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/layer.tar
-rw-r--r-- 1 ec2-user ec2-user 58445312 Jul  1 21:25 a4e2f1136e50ce782b4712f7f31628a9d8d973035072f6d7a2c5728c87270dc0/layer.tar

$ll d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/layer.tar
-rw-r--r-- 1 ec2-user ec2-user 54617088 Jul  1 21:25 d5990701c3a040b2eb442c195e9d62a3936bb91d7ee918c66751b6f164ec490a/layer.tar
```

9d...がとてもサイズが小さい。
まずは9d...を解凍してみる。

```bash
$tar -xvf layer.tar
var/
var/log/
var/log/nginx/
var/log/nginx/access.log
var/log/nginx/error.log
```

これは Dokerfile の以下の箇所に該当してそうです。

>RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

各レイヤーは差分情報のみを保持するのでこのようなファイル構成になってそうです。

次にa4e2f..を解凍してみます。

```bash
$tar -xvf layer.tar
```

書ききれないぐらい大量にファイル及びディレクトリが生成されました。
Dockefile の内容を見ると RUN コマンド内にて && を使って連続で複数のコマンドを実行しており、それによる差分も大きいためにこの様になっていると思われます。

最後の d59... もかなり多くのファイル及びディレクトリが生成されました。

# docker pull/docker push ではどのように各レイヤーをダウンロード・アップロードするのか

`docker pull`はデフォルトで **3つのレイヤーを同時** にダウンロードします

[Concurrent downloads](https://docs.docker.com/engine/reference/commandline/pull/#concurrent-downloads)

>By default the Docker daemon will pull three layers of an image at a time. 

`docker push`はデフォルトで **5つのレイヤーを同時** にアップロードします。

[Concurrent uploads](https://docs.docker.com/engine/reference/commandline/push/#concurrent-uploads)

>By default the Docker daemon will push five layers of an image at a time. 

# f68d6e55e06..って JSON ファイル何？

`docker save`して解凍した時に`f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json` というファイルが出来ていたのでこちらも確認します。

```f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc.json
{
  "architecture": "amd64",
  "config": {
    "Hostname": "",
    "Domainname": "",
    "User": "",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "ExposedPorts": {
      "80/tcp": {}
    },
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": [
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
      "NGINX_VERSION=1.17.1",
      "NJS_VERSION=0.3.3",
      "PKG_RELEASE=1~stretch"
    ],
    "Cmd": [
      "nginx",
      "-g",
      "daemon off;"
    ],
    "ArgsEscaped": true,
    "Image": "sha256:b3589c805dd193e4dc7305c2f550112d1c624d5917df39743cbc6edfe603de02",
    "Volumes": null,
    "WorkingDir": "",
    "Entrypoint": null,
    "OnBuild": null,
    "Labels": {
      "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
    },
    "StopSignal": "SIGTERM"
  },
  "container": "2aa9b07987cb2b14da48fc2c46389920c877d8d2992978b30c08766b0e024611",
  "container_config": {
    "Hostname": "2aa9b07987cb",
    "Domainname": "",
    "User": "",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "ExposedPorts": {
      "80/tcp": {}
    },
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": [
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
      "NGINX_VERSION=1.17.1",
      "NJS_VERSION=0.3.3",
      "PKG_RELEASE=1~stretch"
    ],
    "Cmd": [
      "/bin/sh",
      "-c",
      "#(nop) ",
      "CMD [\"nginx\" \"-g\" \"daemon off;\"]"
    ],
    "ArgsEscaped": true,
    "Image": "sha256:b3589c805dd193e4dc7305c2f550112d1c624d5917df39743cbc6edfe603de02",
    "Volumes": null,
    "WorkingDir": "",
    "Entrypoint": null,
    "OnBuild": null,
    "Labels": {
      "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
    },
    "StopSignal": "SIGTERM"
  },
  "created": "2019-07-01T21:25:40.051159139Z",
  "docker_version": "18.06.1-ce",
  "history": [
    {
      "created": "2019-06-10T23:24:23.197964064Z",
      "created_by": "/bin/sh -c #(nop) ADD file:5ffb798d64089418ef4d3a261df5ad7cfa038eb2ef778db2b92604ac87228d99 in / "
    },
    {
      "created": "2019-06-10T23:24:23.42168058Z",
      "created_by": "/bin/sh -c #(nop)  CMD [\"bash\"]",
      "empty_layer": true
    },
    {
      "created": "2019-06-11T00:02:42.070507226Z",
      "created_by": "/bin/sh -c #(nop)  LABEL maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:10.821974727Z",
      "created_by": "/bin/sh -c #(nop)  ENV NGINX_VERSION=1.17.1",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:10.970434769Z",
      "created_by": "/bin/sh -c #(nop)  ENV NJS_VERSION=0.3.3",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:11.125664497Z",
      "created_by": "/bin/sh -c #(nop)  ENV PKG_RELEASE=1~stretch",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:38.776299791Z",
      "created_by": "/bin/sh -c set -x     && addgroup --system --gid 101 nginx     && adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos \"nginx user\" --shell /bin/false --uid 101 nginx     && apt-get update     && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates     &&     NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62;     found='';     for server in         ha.pool.sks-keyservers.net         hkp://keyserver.ubuntu.com:80         hkp://p80.pool.sks-keyservers.net:80         pgp.mit.edu     ; do         echo \"Fetching GPG key $NGINX_GPGKEY from $server\";         apt-key adv --keyserver \"$server\" --keyserver-options timeout=10 --recv-keys \"$NGINX_GPGKEY\" && found=yes && break;     done;     test -z \"$found\" && echo >&2 \"error: failed to fetch GPG key $NGINX_GPGKEY\" && exit 1;     apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/*     && dpkgArch=\"$(dpkg --print-architecture)\"     && nginxPackages=\"         nginx=${NGINX_VERSION}-${PKG_RELEASE}         nginx-module-xslt=${NGINX_VERSION}-${PKG_RELEASE}         nginx-module-geoip=${NGINX_VERSION}-${PKG_RELEASE}         nginx-module-image-filter=${NGINX_VERSION}-${PKG_RELEASE}         nginx-module-njs=${NGINX_VERSION}.${NJS_VERSION}-${PKG_RELEASE}     \"     && case \"$dpkgArch\" in         amd64|i386)             echo \"deb https://nginx.org/packages/mainline/debian/ stretch nginx\" >> /etc/apt/sources.list.d/nginx.list             && apt-get update             ;;         *)             echo \"deb-src https://nginx.org/packages/mainline/debian/ stretch nginx\" >> /etc/apt/sources.list.d/nginx.list                         && tempDir=\"$(mktemp -d)\"             && chmod 777 \"$tempDir\"                         && savedAptMark=\"$(apt-mark showmanual)\"                         && apt-get update             && apt-get build-dep -y $nginxPackages             && (                 cd \"$tempDir\"                 && DEB_BUILD_OPTIONS=\"nocheck parallel=$(nproc)\"                     apt-get source --compile $nginxPackages             )                         && apt-mark showmanual | xargs apt-mark auto > /dev/null             && { [ -z \"$savedAptMark\" ] || apt-mark manual $savedAptMark; }                         && ls -lAFh \"$tempDir\"             && ( cd \"$tempDir\" && dpkg-scanpackages . > Packages )             && grep '^Package: ' \"$tempDir/Packages\"             && echo \"deb [ trusted=yes ] file://$tempDir ./\" > /etc/apt/sources.list.d/temp.list             && apt-get -o Acquire::GzipIndexes=false update             ;;     esac         && apt-get install --no-install-recommends --no-install-suggests -y                         $nginxPackages                         gettext-base     && apt-get remove --purge --auto-remove -y apt-transport-https ca-certificates && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list         && if [ -n \"$tempDir\" ]; then         apt-get purge -y --auto-remove         && rm -rf \"$tempDir\" /etc/apt/sources.list.d/temp.list;     fi"
    },
    {
      "created": "2019-07-01T21:25:39.534862179Z",
      "created_by": "/bin/sh -c ln -sf /dev/stdout /var/log/nginx/access.log     && ln -sf /dev/stderr /var/log/nginx/error.log"
    },
    {
      "created": "2019-07-01T21:25:39.707598949Z",
      "created_by": "/bin/sh -c #(nop)  EXPOSE 80",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:39.879242256Z",
      "created_by": "/bin/sh -c #(nop)  STOPSIGNAL SIGTERM",
      "empty_layer": true
    },
    {
      "created": "2019-07-01T21:25:40.051159139Z",
      "created_by": "/bin/sh -c #(nop)  CMD [\"nginx\" \"-g\" \"daemon off;\"]",
      "empty_layer": true
    }
  ],
  "os": "linux",
  "rootfs": {
    "type": "layers",
    "diff_ids": [
      "sha256:cf5b3c6798f77b1f78bf4e297b27cfa5b6caa982f04caeb5de7d13c255fd7a1e",
      "sha256:197c666de9dd65f1c350e2c44628c5d530f366c9edf0197373f8603cf9af9e50",
      "sha256:d2f0b6dea592c39bfc4f06a1f6502d58a2fa6d9e6b6cf1aaf0d458d5d61d4515"
    ]
  }
}

```

前半は `docker inspect`と同じような内容が見えます。
後半は各レイヤーの情報が分かり、`empty_layer`を見るとその名称の通り「空のレイヤーか否か」というのが分かる気がします。
最後は「sha256」のようなので確認。

```bash
$sha256sum 9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar
d2f0b6dea592c39bfc4f06a1f6502d58a2fa6d9e6b6cf1aaf0d458d5d61d4515  9de6aebfff35261996e4315105c546a002a8e42be30bc9189851384adc3abf6b/layer.tar
```

合ってそうです。

# 残疑問点

+ マニフェストファイルの形式が [Image Manifest V 2, Schema 2 ](https://docs.docker.com/registry/spec/manifest-v2-2/)でも [Image Manifest V 2, Schema 1 ](https://docs.docker.com/registry/spec/manifest-v2-1/)でもない。centos でもやってみたが同じだったが、現在どのうな状況かまで分からず。
+ `docker pull`の時の動作として最初に Manifest ファイルをダウンロードして各レイヤーを並行してダウンロードして sha256 を確認してそうだが動きのドキュメントなどが確認できず。ソースコードを追うと分かる？