docker system prune
docker system prune [-a] [--volumes]
Risk: Can lose work
What it does
Deletes stopped containers, unused networks, dangling images and build cache.
When to use it
Big clean-up. Read the warning before you type y.
Example
$ docker system pruneIt asks first. y deletes, N keeps.
$ docker container pruneOnly stopped containers.
$ docker image prune -aEvery image no container uses.
$ docker volume pruneUnused unnamed volumes. With -a: all unused volumes!
$ docker builder pruneOld build cache.
Learn it in: Clean up safely · Official docs