docker image ls
docker image prune -a --force --filter "until=240h"
=> Total reclaimed space: 0B
All of the images with no tag are all superseded by the latest
images and are redundant. Why are they not being removed?
Share and learn in the Docker community.
docker image ls
docker image prune -a --force --filter "until=240h"
=> Total reclaimed space: 0B
All of the images with no tag are all superseded by the latest
images and are redundant. Why are they not being removed?
This is actually something Iām not sure either, but I also noticed this some month ago. My guess is that somehow those cache entries depend on a newer image or cache entry, but I donāt have a specific explanation
I just tried to remove one of these images manually with rm <id>
and I got a warning that the image is used by a stopped container and I had to force delete. I donāt know if the --force
in the prune
command is not being respected?
Instead of forcing an image to be deleted, if a container is still using it, delete the container. If you donāt want to delete the container, then you probably donāt want to delete the image. docker ps -a
shows stopped containers.
If you read the documentation or the output of docker system prune --help
, you can see the force option is not for the same purpose. With prune, it will just not ask back, while with rm, an image can be deleted even if a container is using it. Which can lead to other strange behaviors, so I would not recommend it.
Ahh I seeā¦I was using docker container ls
instead of docker ps
so thatās why I couldnāt see all of the other containers.
I ran docker container prune
and then docker image prune
and all of the unwanted images deleted successfully.
Thank you
docker ps
is an alias to docker container ls
. You can use both, just pass -a
or --all
as well that shows all containers, not just running containers.