0

Below is my terminal log.

peter@web-server:~$ sudo docker system prune --all
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache

Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
peter@web-server:~$ sudo docker images -a
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    b48bd51fa2b9   3 weeks ago     408MB
<none>       <none>    aebce4827c29   3 weeks ago     427MB
website      005       58923eb21c4f   3 weeks ago     427MB
<none>       <none>    24920f410c4b   3 weeks ago     427MB
mysql        8.0       05db07cd74c0   3 weeks ago     565MB
<none>       <none>    37cb44321d04   14 months ago   408MB
peter@web-server:~$ sudo docker images --filter=reference=aebce4827c29
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
peter@web-server:~$ sudo docker images --filter=reference=b48bd51fa2b9
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
peter@web-server:~$ sudo docker images --filter=reference=24920f410c4b
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
peter@web-server:~$ sudo docker images --filter=reference=37cb44321d04
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
peter@web-server:~$ sudo docker rmi b48bd51fa2b9
Error response from daemon: conflict: unable to delete b48bd51fa2b9 (cannot be forced) - image has dependent child images
peter@web-server:~$ sudo docker rmi aebce4827c29
Error response from daemon: conflict: unable to delete aebce4827c29 (cannot be forced) - image has dependent child images
peter@web-server:~$ sudo docker rmi 24920f410c4b
Error response from daemon: conflict: unable to delete 24920f410c4b (cannot be forced) - image has dependent child images
peter@web-server:~$ sudo docker rmi 37cb44321d04
Error response from daemon: conflict: unable to delete 37cb44321d04 (cannot be forced) - image has dependent child images

I would like to remove the dangling Docker images, but the command is not working. How can I solve this issue? Thank you, guys.

  • The error message indicates that another (still used?) image is depending on the image you are attempting to delete. The `website` image is probably a good candidate. Also, is the following question of any use for you? https://stackoverflow.com/questions/38118791/can-t-delete-docker-image-with-dependent-child-images – Rob Jun 21 '23 at 07:21
  • Thanks Rob, your answer is very helpful and the other stackoverflow question helps a lot! – Peter Chan Jun 21 '23 at 14:36

1 Answers1

1

You're using the docker images -a option, which shows some additional intermediate images that are part of Docker's layer system. These images don't use up any additional space (their size is counted in the final image size); you can run them if you really want to but they're (usually) not useful.

I'd just remove the -a option, which will hide the <none> images. They're harmless and you don't need to worry about them.

You can see this with pretty much any Docker image. You might try comparing for example

docker pull redis
docker images -a > images-1.txt
docker rmi redis
docker images -a > images-2.txt
diff images-1.txt images-2.txt

and you'll see several hidden <none> images get removed with the docker rmi invocation.

In your specific setup, docker rmi website:005 will probably remove a couple of the <none> images, but some of them probably belong to the mysql:8.0 image as well.

David Maze
  • 130,717
  • 29
  • 175
  • 215