您可以在/ var / lib / docker / aufs / layers文件夹中找到图像的层。提供是否将存储驱动程序配置为aufs(默认选项)
例:
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0ca502fa6aae ubuntu "/bin/bash" 44 minutes ago Exited (0) 44 seconds ago DockerTest
现在查看使用图像“ Ubuntu”创建的容器的各层;转到/ var / lib / docker / aufs / layers目录,然后将文件以容器ID开头(此处为0ca502fa6aae *)
root@viswesn-vm2:/var/lib/docker/aufs/layers# cat 0ca502fa6aaefc89f690736609b54b2f0fdebfe8452902ca383020e3b0d266f9-init
d2a0ecffe6fa4ef3de9646a75cc629bbd9da7eead7f767cb810f9808d6b3ecb6
29460ac934423a55802fcad24856827050697b4a9f33550bd93c82762fb6db8f
b670fb0c7ecd3d2c401fbfd1fa4d7a872fbada0a4b8c2516d0be18911c6b25d6
83e4dde6b9cfddf46b75a07ec8d65ad87a748b98cf27de7d5b3298c1f3455ae4
这将通过运行显示相同的结果
root@viswesn-vm2:/var/lib/docker/aufs/layers# docker history ubuntu
IMAGE CREATED CREATED BY SIZE COMMENT
d2a0ecffe6fa 13 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
29460ac93442 13 days ago /bin/sh -c sed -i 's/^#\s*\ (deb.*universe\)$/ 1.895 kB
b670fb0c7ecd 13 days ago /bin/sh -c echo '#!/bin/sh' > /usr/sbin/polic 194.5 kB
83e4dde6b9cf 13 days ago /bin/sh -c #(nop) ADD file:c8f078961a543cdefa 188.2 MB
查看完整的图层ID;在历史命令中使用--no-trunc选项运行。
docker history --no-trunc ubuntu
docker history myimage
,您将看到每个层的大小。更一般而言,在图像上,您可以docker history myimage | awk 'NR>1 {print $1}' | xargs docker inspect --format '{{ ((index .ContainerConfig.Cmd ) 0) }}'
查看发出了哪些命令来创建图像