How to delete all docker artifacts on a host

This post show a script to cleanup your system from all containers, downloaded docker images and other docker artifacts (e.g. you want to use the host for a completely new project).

The script consists out of three docker commands:

#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Delete all other docker artifacts
docker system prune

The first command removes all containers. The second command removes all images and the third command cleans up all leftover.

Leave a Reply

Your email address will not be published. Required fields are marked *