When running Docker for a long time, there are a lot of images in system. How can I remove all unused Docker images at once safety to free up the storage?
In additio
Assuming you have Docker 1.13 or higher you can just use the prune commands. For your question specifically for removing old images, you want the first one.
# Remove unused images
docker image prune
# Remove stopped containers.
docker container prune
# Remove unused volumes
docker volume prune
# Remove unused networks
docker network prune
# Command to run all prunes:
docker system prune
I would recommend not getting used to using the docker system prune
command. I reckon users will accidentally remove things they don't mean to. Personally, I'm going to mainly be using the docker image prune
and docker container prune
commands.