Skip to content

Instantly share code, notes, and snippets.

@Siva-Charan
Last active October 9, 2022 11:18
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save Siva-Charan/db7bd84ad2ca2b0779d87a75e6bb4176 to your computer and use it in GitHub Desktop.
Save Siva-Charan/db7bd84ad2ca2b0779d87a75e6bb4176 to your computer and use it in GitHub Desktop.
Docker: How to find the dependent child images?

Find the dependent child images on Docker

When you try to remove the docker image with the following command

docker rmi 6795374be8c1

Sometimes you might be facing below error:

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

Below is the Docker command line used to find the dependent child images

Format:

docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since= -q)

Example:

docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=6795374be8c1 -q)

Result:

sha256:1d1f94c972fc8d75a34135f9ff551617680c508f7ad17efda09048b4e805g1w3

Here sha256:1d1f94c972fc8d75a34135f9ff551617680c508f7ad17efda09048b4e805g1w3, the bold value is your dependent child image

@nonunicorn
Copy link

docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=6795374be8c1 -q)
This will also return not dependent images, but that were created since specified one was. You have to additionally filter with parent id like here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment