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

后端 未结 12 872
耶瑟儿~
耶瑟儿~ 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:06

    This is what I did in order to preserve my final "image" (layer, really - which is what threw me off, as I am just getting into docker builds).

    I was getting the whole "... cannot be forced..." message. I realized I couldn't delete the images I didn't need because they are not really independent images created by 'docker commit'. My issue was, I had several images (or layers) between the base image and my final, and just trying to clean up is where I met the error/warning about the child and parent.

    1. I exported the final image (or layer, if you will) out to a tarball.
    2. I then deleted all the images I wanted to, including my final - I have it saved to a tarball so, while I wasn't sure if I would be able to use it, I was just experimenting.
    3. I then ran docker image load -i FinalImage.tar.gz. The output was something like:

    7d9b54235881: Loading layer [==================================================>]  167.1MB/167.1MB
    c044b7095786: Loading layer [==================================================>]  20.89MB/20.89MB
    fe94dbd0255e: Loading layer [==================================================>]  42.05MB/42.05MB
    19abaa1dc0d4: Loading layer [==================================================>]  37.96MB/37.96MB
    4865d7b6fdb2: Loading layer [==================================================>]  169.6MB/169.6MB
    a0c115c7b87c: Loading layer [==================================================>]    132MB/132MB
    

    Loaded image ID: sha256:82d4f8ef9ea1eab72d989455728762ed3c0fe35fd85acf9edc47b41dacfd6382

    Now, when I list with 'docker image ls', I only have the original base image, and the final image I previously saved to a tarball.

    [root@docker1 ~]# docker image ls
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    httpd               import              82d4f8ef9ea1        3 days ago          747MB
    centos              httpd               36540f359ca3        5 weeks ago         193MB
    

    My system is 'clean' now. I only have the images I want. I even deleted the base image without a problem.

    [root@docker1 ~]# docker rmi 36540f359ca3
    Untagged: centos:httpd
    Untagged:     centos@sha256:c1010e2fe2b635822d99a096b1f4184becf5d1c98707cbccae00be663a9b9131
    Deleted: sha256:36540f359ca3b021d4b6a37815e9177b6c2bb3817598979ea55aee7ecc5c2c1f
    

提交回复
热议问题