Can't delete image with children

Hi
I am trying
docker rmi c565603bc87f
Error response from daemon: conflict: unable to delete c565603bc87f (cannot be forced) - image has dependent child images
So i can’t delete image even with -f flag. How to delete image then and all of its children ?

uname -a
Linux goracio-pc 4.4.0-24-generic #43-Ubuntu SMP Wed Jun 8 19:27:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

docker version
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64

Server:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64

Greetings goracio,

I am having the exact same problem:

root@seltzer:~/docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vm370suite705 latest e7dd249ea187 25 hours ago 1.271 GB
v01 latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite_2016-07-05 latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite_2016 latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite_2016-06-30-7 latest ebb63b5a6bb0 5 days ago 1.271 GB
vm370suite_2016-06-30-6 latest e843e6b2c9fd 5 days ago 1.271 GB
vm370suite_2016-06-30-5 latest abc25f2ec8f2 5 days ago 1.168 GB
vm370suite_2016-06-30-4 latest 5050914ddc99 5 days ago 1.065 GB
vm370suite_2016-06-30-3 latest c105a959afa7 6 days ago 1.065 GB
vm370suite_2016-06-30-2 latest 46bee88ae25d 6 days ago 1.065 GB
nate/dockviz latest 3ee5f8ba9d07 3 weeks ago 6.091 MB
ubuntu latest 2fa927b5cdd3 5 weeks ago 122 MB
debian latest 1742affe03b5 6 weeks ago 125.1 MB

Note that the containers with the same key are:

root@seltzer:~/docker# docker images | grep adbd
v01 latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite_2016-07-05 latest 5c07b467adbd 5 days ago 1.271 GB
vm370suite_2016 latest 5c07b467adbd 5 days ago 1.271 GB

These do not want to budge… see?
root@seltzer:~/docker# docker rmi 5c07b467adbd
Error response from daemon: conflict: unable to delete 5c07b467adbd (cannot be forced) - image has dependent child images

What to do?

I am also,helping
error codeing:

Error response from daemon: conflict: unable to delete 6ed35665f88f (cannot be forced) - image has dependent child images

Hi there, i had the same problem than you, so i check on the internet and i made me sad that the answer exist on Stack over flows but not on the Docker’s forum.

  1. open your terminal and enter :
    docker inspect --format=’{{.Id}} {{.Parent}}’ $(docker images --filter since=<image_id> -q)
    where you replace <image_id> by your image id (Yeah, man, obviously)
    It will kill every children
  2. then , write :
    docker rmi <image_id>
  3. if it tell you that it is link to a docker so remove it too with the command :
    docker rm < docker_id>
    and then go back to point 2) to end the process .

Normally it should work .

you can find the source below : https://stackoverflow.com/questions/38118791/can-t-delete-image-with-children

Umm… I am also having issues with deleting unused images and the command above does not seem to help.

docker image rm b602d8daff1b

Error response from daemon: conflict: unable to delete b602d8daff1b (cannot be forced) -image has dependent child images

docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=b602d8daff1b -q) sha256:efb1c1cc33445af98f3cfaeff6d1edc45a05fe6500af3030597022599f2e053e sha256:80c3eb04058d5fbb55adcfc882f201e55f06ab851d443fd55a8fea212f101487 sha256:efb1c1cc33445af98f3cfaeff6d1edc45a05fe6500af3030597022599f2e053e sha256:80c3eb04058d5fbb55adcfc882f201e55f06ab851d443fd55a8fea212f101487 sha256:64effa095d9e1e36a50a54764e1a3a9e7640eff4babb85e395caa86b7d3e1b26 sha256:78b258e36eed66baac857cd8aecf4f23a0c2241aa19a0debfa3381ab5b4027f4 sha256:b80fcde531bfb41e1d7e7a1440a022ed182bc47c05c71bf8673b69f2b56c415a sha256:dffde1a323cc9923581cd7f466941356291f9711007a9d4d7e4666f5e1a2265e sha256:e81eb098537d6c4a75438eacc6a2ed94af74ca168076f719f3a0558bd24d646a sha256:8d84c7940aa6ea74016d9b6f6ab6c65aa797cfd79b9b7d5ca7d3277b2cc7d30f sha256:f991c20cb5087fdd01fa7a2181f0a123a54d697681cf3723370bf50566d2e7cf sha256:f832373b943bd47085aa000abbfc4d0f45448a71ace9fcb2adcc45b1770e1553 sha256:e9e49a465debc413cfb3b8a9dfb979e99dd28962d4966027ec4a232c0a840342 sha256:4879790bd60d439cfe39c063660eef7af525d5f6f1cbb701a14c7cfc11cbfcf7 sha256:ccf40fb5ec0f3621f30e2d8c11f597acf1a80b38be344e79bf7243a0643f0dd1 sha256:c0da8809485069b292cb2e8fbefeb68122feff17e16d47ba482bdf413d936d60 sha256:f3e6b23ea899a2fcce49d07507753f03848fde23e83be1efec7ec0fe465f6528 sha256:83233e84a4f13f60e8ca4bad98af5ca56a86c10f262111c105de901aad79d9b0 sha256:b08ad1c31f8d83408117e3dbdc38fa518636983e78eda0e8b7a0b1146689f489 sha256:062267097b77e3ecf374b437e93fefe2bbb2897da989f930e4750752ddfc822a sha256:6feeb9555e5534ac28a08d77a05f172384fea290eda14122fec4402886fcb907 sha256:d583b7624c1a7705bf2406860330ea24cb6f9dacf3357e59ba2849958cc73e5a sha256:4095d6d460cdcf85ec19b5fd15d354e2827419cc416f311c54cc9671a90a2b1d sha256:ea4c82dcd15a33e3e9c4c37050def20476856a08e59526fbe533cc4e98387e39 sha256:75835a67d1341bdc7f4cc4ed9fa1631a7d7b6998e9327272afea342d90c4ab6d sha256:524b2f546192519f6c6371244eb602d2837f292979ddb012a4d402a07d686a3c sha256:3805ed7a29c0155c5ca6f26887d5202778297629c8e0ccea7e0fc8d0e0c6cff6 sha256:d8114f21814289a2435987e861824cee0bff0eb8ef734b43c04957678b74751d sha256:02c4c19c9f5aab3b894ed55b28a0a2babb6aa9b335ada9dda9d55ecbc553f066 sha256:80a9b6ba6f847150942087ff427a0faa1912fcfea0115b546ceccb780cf1b831 sha256:00ead811e8ae868201e7fd256dee6b8ef778b7bf6f57ca88785914fceac2facb sha256:084ec18124c8ccb08c7df98492db211f19a6a3d9e159cc88d1281c634b90bb87 sha256:06144b2878448774e55577ae7d66b5f43a87c2e44322b3884e4e6c70d070b262 sha256:98103a446f7fe22674879a1393494795d8102e6488737291c31e8468f8fb29d8 sha256:0f8f89498ea265e5e26fecee192bf33dc5fca77aa177db36057c2b488a00eded sha256:74abca7549bf70579cd206fcde0d94c49da9e6cc323cdf2a1b3b380da4eabb88 sha256:9192ec7cd4c2e82ca5f0003865159410c9bd476099159f4e71c524b4ffbee23a sha256:f8422ad2c52b0f5e87a0cd1fbe344a4661d37d2a2fe99e847c2b6adc8c344d08 sha256:61d053fc271ce1313896a2edf7719fb3b68637b53397e61d8114793b39e9ae65 sha256:ed5db6e669ffe319a2b56409f9a1daac305e3871ff2a5d22505a1d8dcab3ce82 sha256:eb5619fb027cfd867da0e90f87c1e9f5658e0ae8fd50abcba2a26b345a6bfb04 sha256:76cdf09f068cb04ace9743bc7ab41b5186605929064c8977effb6cb5c4715b47 sha256:1b3ec9d977fb413627aca6244b27538013905167db25702a500474616ac2e3c8 sha256:a01dd3dbdf0f4cde9b673a4509d0a8f8c3eaabed40c58da8832ecf72ebbf6d01 sha256:8b0c8cac76b209a0ee1d197349f243e30c230e366d88c17f6e8316027064e2fc sha256:4cf22292dddc87d37ea2c12462da40ce61404fc088ac3a620add8825ba3c2c2c sha256:792af84ff00bac42fb8ba73014e1ccf055b861cc845872635c3e63d80334f516 sha256:c2159ded020fd078a8c950d97c7259aaf4dc1ffba8dbeff2bfbba265ceaaa58e sha256:1c80dc77fa956df0ab3cc13b1650f2a17311a2abb80c1291211c8605415af134 sha256:2df7788a36a41a20def4429fa583641d4b9ad00e240644a2bb8e7d66786782c8 sha256:83e49dadbe63e2e8e9488b4572f5b0330d75c21daabf091658a5006a063edff7 sha256:caeeb1d80797c752ce987b299d360cb8453de1dd0690349ee7cc7b7c8fce17ef sha256:b602d8daff1b146c932ec1c89c92824c8ae2fd92fd030206fdaefa292b8cf848 sha256:c076c745b43294999ace4edfa83de6d41a12c7c5e740ad23e08c78ae3c69a8ec sha256:0373ddb273e498dff5d503bf0ecb5b01473ac3cecbaac11a1918ed7e77737808 sha256:0fa5972fcdfa9ca7a60233799c39b6d3a93e5ebf9ab219bfbd8c46c1c34bf29c sha256:c6de2375169593787a7c8d802cc94b2e7db04ec2c814903c9345261765a200e7 sha256:a63c66e1e552d154d1a57e34943433197272d2fd30a517a4e3ca9d199cacef34 sha256:00fd29ccc6f167fa991580690a00e844664cb2381c74cd14d539e36ca014f043 sha256:67759a80360cbaef77ec1eee8aa0590f07ba04c26ef496efbc90391f217fd9d6 sha256:69cc4b9c4273fad7b8016bff822577da436120bc81de00bb9d3376d8f5229bfb sha256:7d83a47ab2d2d0f803aa230fdac1c4e53d251bfafe9b7265a3777bcc95163755 sha256:7616c1e28efae43baf72bddacbf8183dce700eb9b01c0b920b64195f0da1f671 sha256:bf3a35c4b7941d9933f33e91460c3319a5e16ff163da614aad086d44a73e06be sha256:6653decfdc56ddc7b208d2f7b6e329b93a69260a12cd6b9a1a9129883ee73ac7 sha256:a00814f23580a0dd680475d3a9bc981e8c7daeeb4e38984d92fa4db47d76121d sha256:3afd47092a0ef2877da88b5dad059a0a86ac6d64bead3d4b95b6ff0583cf1239 sha256:7ed1f6a3422e50ed6d877d7847b29d1437e5c29270942fb9e419fbad5a6e5244 sha256:cc59f6a8b93db6fda2fe950475340a7c45a400250a5ef8fc6a0ff8a64919cf2f sha256:ff730e66912cb13d00ef6e33b605335acd2feb606b97b9c3ed7016c6f870c996 sha256:15b7f00fa1d1f5d8b512e2cb5704424eee1b1316e0a16b153037fb83dfbeae85

The format of the above was a bit weird too.

So any idea’s what is going on?

The Docker thread should provide a solution but doesn’t, and its an impediment on my development environment.

@kscott5
I’m not sure, but do you have first to delete the stopped container before removing the image?!

@jeremyy55
It doesn’t work for me too!:frowning_face:

Edit: Solved!:sunglasses:
You have to enter the full id (not a part of the id only), then the output will show some sha:256 hashes with one and the same id.
Then you can remove the image with

docker rmi id

Please refer to the below command to fix the issue as i was facing the same error:
docker rmi < image id > -f
this will forcefully delete the children while removing image.

Hi there,
If you run the below command to see the docker hidden images in the background.
docker images -a

Search for the child image. Once that is confirmed, run the following image using the command:
docker rmi $(docker images -a | grep “< none>” | awk ‘{print $3}’)

This will remove all the unused images that are not being used.
Note: in the query above remove space before none in "< none>"

Hello everyone, to delete an image you have to delete all the images from the same repository

for example if you want to delete an image based on Ubuntu you have to put all the id that are from the same repository

Why doesn’t docker simply have a command like `docker untag <tag or id>??? Deleting all images just to delete a stubborn/pregnant one seems like a bit of “Solomon’s Sword” IMHO.

If one or more tags point to an image id, it is not possible to delete the image by image id.

It becomes necessary to delete each tag with docker rmi ${repo}:${tag}, until one tag remains, which then can be deleted by either the tag or the image id. Only the last rmi acualy deletes image layers, every previous command in fact untags the “pointer” to the image id.

Thus said, I feel docker image rm | docker rmi already implement untag and remove. In case of ambiguity (n:>1 tags point to the image id), it will just untag otherwiese delete the image layers and meta-data.

1 Like

From recent experience, I believe that you arrive at a “Catch-22” when the existing tag is <none>, however. Maybe it’s just me, but I have yet to figure out how to rmi such a null tagged object, especially when the prescient error text mentions ‘(cannot be forced).’

Indeed Catch-22. an image entry where multiple repo:tag <none>:<none> point to the same image id, can’t be deleted that way.

When an image is build with multiple tags, then re-build with multiple tags → this should create the scenario that @amondale refers to.

Well spoted! I have no idea how to delete those image entries, and if they are concidered as dangling images, and as such can be deleted with docker image prune. The last 7 years I have never been in the situation - though typicaly my images are build inside a disposable build container and pushed to a private repository.

Thanks for confirming, Metin! These none stragglers are artifacts of the docker pull command, or at least the docker pull, docker tag sequence. They cannot be pruned either; the only way to remove is to rmi the pulled image (which became the parent of the “non-dangling” <none> and then it can be rmi’ed by id, and the pull and tag commands re-issued. Not sure why the “ghost” image is being created, possibly as a backup, but I would think “untag” would be the right way to go for these images.

I had the same issue and here is how I managed to solve it:

  • First, you need to change the tag of the specific image you want to remove.

SYNTAX:

docker tag container_id repo_name:new_tag_name

# example
docker tag 1234567er34r davesaah/my-repo:old
  • Next, remove the image with the new tag created using docker rmi

SYNTAX

docker rmi repo-name:tag

# using the previous example
docker rmi davesaah/my-repo:old

This will remove the dangling image that has dependent child images.
Everything should work fine after that.
I hope this helps :blush:

2 Likes

Actually that approach merely “untags” the repo-name:tag image, because the orphan image is the parent.

thank you this solution is the best practice to do, and totally work 100%, but i think docker need to simplify this way.

thanks @davesaah