dockerdocker-imagedocker-cli

How to see docker image layers when image tag is not present


I was trying various options of "docker image history" command to see the image layers used to build the image on my local machine.

There is a nginx image on my system which has no tags assigned. So "docker images" command lists the following images in my system.

enter image description here

I tried to find layer details for nginx image using following command :

docker image history nginx

But as the tag name is not specified, docker-cli considers it default "latest" tag which is not present on my system and I am getting following error :

Error response from daemon: No such image: nginx:latest

I tried the same command with "none" as tag but it also failed with following error :

docker image history nginx:none
Error response from daemon: No such image: nginx:none

Any suggestions ? How can we see layers of an images which does not have tag assigned.


Solution

  • I found --filter option for docker images command which we can use to find dangling/untagged images as below :

    docker images -f "dangling=true" --quiet
    

    We can use this command to list image layers for the untagged image as below :

    docker image history  $(docker images -f "dangling=true" --quiet)