How to get the list of dependent child images in Docker?

后端 未结 12 850
耶瑟儿~
耶瑟儿~ 2020-12-12 11:22

I\'m trying to remove an image and I get:

# docker rmi f50f9524513f  
Failed to remove image (f50f9524513f): Error response from daemon: conflict: unable to          


        
12条回答
  •  执念已碎
    2020-12-12 12:24

    I cooked up this to recursively find children, their repo tags, and print what they're doing:

    docker_img_tree() {
        for i in $(docker image ls -qa) ; do
            [ -f "/tmp/dii-$i"  ] || ( docker image inspect $i > /tmp/dii-$i)
            if grep -qiE 'Parent.*'$1 /tmp/dii-$i ; then
                echo "$2============= $i (par=$1)"
                awk '/(Cmd|Repo).*\[/,/\]/' /tmp/dii-$i | sed "s/^/$2/"
                docker_img_tree $i $2===
            fi
        done
    }
    

    Don't forget to delete /tmp/dii-* if your host isn't secure.

提交回复
热议问题