I E

Docker Cleanup Commands

7 November, 2020

I’ve Googled this one too many times, so I’m writing it here for future reference.

#! /usr/bin/env bash

# remove containers
docker ps --all --format "{%raw%}{{.ID}}{%endraw%}" | xargs docker rm

# remove images
docker images --format "{%raw%}{{.ID}}{%endraw%}" | xargs docker rmi -f

# remove volumes
docker volume prune

# remove build cache
docker builder prune