docker image history
Table of Contents:
Command Name:
docker image history
Description:
docker image history:
Show the history of an image
Syntax:
easywhatis$ docker image history --help
Usage: docker image history [OPTIONS] IMAGE
Show the history of an image
Options:
--format string Pretty-print images using a Go template
-H, --human Print sizes and dates in human readable format (default true)
--no-trunc Don't truncate output
-q, --quiet Only show numeric IDs
easywhatis$
Example:
easywhatis$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest ed21b7a8aee9 12 days ago 127MB
ubuntu latest 4e5021d210f6 3 weeks ago 64.2MB
busybox latest 83aa35aa1c79 4 weeks ago 1.22MB
easywhatis$ docker image history ubuntu --no-trunc
IMAGE CREATED CREATED BY SIZE COMMENT
sha256:4e5021d210f65ebe915670c7089120120bc0a303b90208592851708c1b8c04bd 3 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 3 weeks ago /bin/sh -c mkdir -p /run/systemd && echo 'docker' > /run/systemd/container 7B
<missing> 3 weeks ago /bin/sh -c set -xe && echo '#!/bin/sh' > /usr/sbin/policy-rc.d && echo 'exit 101' >> /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && dpkg-divert --local --rename --add /sbin/initctl && cp -a /usr/sbin/policy-rc.d /sbin/initctl && sed -i 's/^exit.*/exit 0/' /sbin/initctl && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes && echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests 745B
<missing> 3 weeks ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 987kB
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:594fa35cf803361e69d817fc867b6a4069c064ffd20ed50caf42ad9bb11ca999 in / 63.2MB
easywhatis$
easywhatis$ docker history ubuntu
IMAGE CREATED CREATED BY SIZE COMMENT
4e5021d210f6 3 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 3 weeks ago /bin/sh -c mkdir -p /run/systemd && echo 'do... 7B
<missing> 3 weeks ago /bin/sh -c set -xe && echo '#!/bin/sh' > /... 745B
<missing> 3 weeks ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 987kB
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:594fa35cf803361e6... 63.2MB
easywhatis$
Format the output:
Sometimes we need to format the output in human readable format.
(–format) will be useful in that case.
The formatting option (–format) will pretty-prints history output using a Go template.
There are few placeholders which we can use and those are as go templates standards.
Placeholders Description
.ID Image ID
.CreatedSince Created Since
.CreatedAt Created At
.CreatedBy Created By
.Size Image Size
.Comment Image Comment
easywhatis$ docker image history --format "{{.ID}}: {{.CreatedSince}}" ubuntu
4e5021d210f6: 3 weeks ago
<missing>: 3 weeks ago
<missing>: 3 weeks ago
<missing>: 3 weeks ago
<missing>: 3 weeks ago
easywhatis$ docker image history --format "{{.ID}}-- {{.CreatedSince}}" ubuntu
4e5021d210f6-- 3 weeks ago
<missing>-- 3 weeks ago
<missing>-- 3 weeks ago
<missing>-- 3 weeks ago
<missing>-- 3 weeks ago
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago
Image ID - <missing>, Created Since -- 3 weeks ago
Image ID - <missing>, Created Since -- 3 weeks ago
Image ID - <missing>, Created Since -- 3 weeks ago
Image ID - <missing>, Created Since -- 3 weeks ago
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}, Created At => {{.CreatedAt}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:20+05:30
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}, Created At => {{.CreatedAt}} || {{.CreatedBy}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c #(nop) CMD ["/bin/bash"]
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c mkdir -p /run/systemd && echo 'do...
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c set -xe && echo '#!/bin/sh' > /...
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 ||
/bin/sh -c [ -z "$(apt-get indextargets)" ]
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:20+05:30 || /bin/sh -c #(nop) ADD file:594fa35cf803361e6...
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}, Created At => {{.CreatedAt}} || {{.CreatedBy}} ## size = {{.Size}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c #(nop) CMD ["/bin/bash"] ## size = 0B
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c mkdir -p /run/systemd && echo 'do... ## size = 7B
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c set -xe && echo '#!/bin/sh' > /... ## size = 745B
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c [ -z "$(apt-get indextargets)" ] ## size = 987kB
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:20+05:30 || /bin/sh -c #(nop) ADD file:594fa35cf803361e6... ## size = 63.2MB
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}, Created At => {{.CreatedAt}} || {{.CreatedBy}} ## size = {{.Size}} || Comments {{.Comment}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c #(nop) CMD ["/bin/bash"] ## size = 0B || Comments
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c mkdir -p /run/systemd && echo 'do... ## size = 7B || Comments
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c set -xe && echo '#!/bin/sh' > /... ## size = 745B || Comments
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c [ -z "$(apt-get indextargets)" ] ## size = 987kB || Comments
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:20+05:30 || /bin/sh -c #(nop) ADD file:594fa35cf803361e6... ## size = 63.2MB || Comments
easywhatis$ docker image history --format "Image ID - {{.ID}}, Created Since -- {{.CreatedSince}}, Created At => {{.CreatedAt}} || {{.CreatedBy}} ## size = {{.Size}} || Comments: {{.Comment}}" ubuntu
Image ID - 4e5021d210f6, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c #(nop) CMD ["/bin/bash"] ## size = 0B || Comments:
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:22+05:30 || /bin/sh -c mkdir -p /run/systemd && echo 'do... ## size = 7B || Comments:
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c set -xe && echo '#!/bin/sh' > /... ## size = 745B || Comments:
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:21+05:30 || /bin/sh -c [ -z "$(apt-get indextargets)" ] ## size = 987kB || Comments:
Image ID - <missing>, Created Since -- 3 weeks ago, Created At => 2020-03-21T00:50:20+05:30 || /bin/sh -c #(nop) ADD file:594fa35cf803361e6... ## size = 63.2MB || Comments:
easywhatis$