Docker Image List And History

IMAGE LIST

docker image ls command is used to list the docker images.

In the image below we can see the list of images on running the docker image ls command.

learning-ocean:~ gaurav$ docker image ls
REPOSITORY                           TAG                               IMAGE ID       CREATED         SIZE
ubuntu                               14.04                             13b66b487594   3 months ago    197MB
learning-ocean:~ gaurav$

We can also use the --format option along with the ls command to format the output of the ls command as required. In the below command we are printing ID and Repository as comma-separated values using the --format option.

learning-ocean:~ gaurav$ docker image ls --format '{{.ID}} , {{.Repository}}'
13b66b487594 , ubuntu
learning-ocean:~ gaurav$

Similarly, in the below command, we are using the --format option to print Tag along with the ID and Repository.

learning-ocean:~ gaurav$ docker image ls --format '{{.ID}} , {{.Repository}} - {{.Tag}}'
13b66b487594 , ubuntu - 14.04
learning-ocean:~ gaurav$

We can also use the following command(in the image below) to list the docker images.

learning-ocean:~ gaurav$ docker images
REPOSITORY                           TAG                               IMAGE ID       CREATED         SIZE
ubuntu                               14.04                             13b66b487594   3 months ago    197MB
learning-ocean:~ gaurav$

Docker Image History

docker image history command can be used to show the history of the specified image.

In the below image we are running the history command to check the history of an image named 'jenkins'.

learning-ocean:~ gaurav$ docker image history ubuntu:14.04

We get the following output-

learning-ocean:~ gaurav$ docker image history ubuntu:14.04
IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
13b66b487594   3 months ago   /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>      3 months ago   /bin/sh -c mkdir -p /run/systemd && echo 'do…   7B
<missing>      3 months ago   /bin/sh -c [ -z "$(apt-get indextargets)" ]     0B
<missing>      3 months ago   /bin/sh -c set -xe   && echo '#!/bin/sh' > /…   195kB
<missing>      3 months ago   /bin/sh -c #(nop) ADD file:276b5d943a4d284f8…   196MB
learning-ocean:~ gaurav$