0

I am working on a microservice with several docker containers. Using docker-compose creates the images I want but also several other copies of images which fill up my disk space. What are the use of this other child images and can I stop them from being created since they are using up my memory. Please note they are not really "dangling" they just appear on build.

composetest_web image has 5 child images below it.

Denn
  • 159
  • 11
  • Question about your error: https://stackoverflow.com/questions/38118791/can-t-delete-docker-image-with-dependent-child-images – devna Jan 21 '20 at 08:19
  • How are you seeing these images? Why do you think they're causing problems? Can you provide a [mcve]? – David Maze Jan 21 '20 at 10:21

1 Answers1

2

The images are the intermediate layers resulted from docker build. They are the parent layers for your final image and cannot be removed as your latest image actually refers to them.

Only those images which are not referenced by any other layers can be removed. These images are called dangling. You can use the following command to remove the dangling images:

docker rmi $(docker images -f "dangling=true" -q)

Shashank V
  • 7,017
  • 1
  • 11
  • 32
  • Well trying to delete either of the dangling images gives the error [Error response from daemon: conflict: unable to delete c565603bc87f (cannot be forced) - image has dependent child images] – Denn Jan 21 '20 at 07:31
  • What do you mean by "either of the dangling images"? What is the output of `docker images -f "dangling=true" -q`? – Shashank V Jan 21 '20 at 07:32
  • It gives a list of image ids, when I list the images again they are still on the list and when I try to delete them, I get the error above – Denn Jan 21 '20 at 07:47
  • What is your docker version? It should have worked. You can also try [`docker image prune`](https://docs.docker.com/engine/reference/commandline/image_prune/). – Shashank V Jan 21 '20 at 08:24
  • My docker version is 18.09 and the prune command does not really get any dangling images... I am wondering, aren't all those untagged images dangling? why are they not being deleted then? – Denn Jan 21 '20 at 08:29
  • Like I said in my answer, all untagged images are not dangling. Please read this article - https://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/ – Shashank V Jan 21 '20 at 08:31
  • I appreciate the blog.. but mind you my images are several express servers and two react frontends. I have the node images pulled and used in building my custom images.. After checking on parent dependency, about four images are dependent on either of my created image.. why are they so many? – Denn Jan 21 '20 at 08:50