简体   繁体   中英

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.

在此处输入图像描述

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.

Try using ID instead of name with tag.

Let say that I have this output of docker images

REPOSITORY TAG      IMAGE ID       CREATED      SIZE
postgres   <none>   1f0815c1cb6e   7 weeks ago  314M

I can use docker image history and specify the ID or part of it sufficient to identify the image in this context.

docker image history 1f0
docker history <your-docker-image-id>

In your case it is as follows:

docker history 7ce4f91ef623

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM