Recently I started using Docker in my internship and sometimes you just mess up your docker images and containers, so you wanted to start from clean but first you need to remove all images and containers of Docker locally.
# Delete all Docker containers
docker rm -f $(docker ps -a -q)
# Delete all Docker images
docker rmi -f $(docker images -q)
Also there is a new docker command, that will delete all unused images and volumes.
docker system prune --all --force
You can read more about this command here
Follow me on GitHub and Twitter
Cheers!
Top comments (2)
Hi Shivam, thanks for sharing this trick with us.
You can also go deeper and prune all networks with this command (if you don't use
docker system prune
):The same thing goes for the volumes:
Nice! There is also
docker container prune
for the same.