Skip to content

Removal

Docker action always involving a large amount of cache, e.g. layers, docker image…etc

But in our development environment, it could accumulate easily after a few projects, which results in the out of storage or not enough memory for docker execution.

In this page, there are various docker technique for cleaning useless storage.

All-in-One

clean up any resources — images, containers, volumes, and networks

# — that are *dangling* (not tagged or associated with a container):
docker system prune

# Or — all stopped containers and all unused images
docker system prune -a

Images

Single image

docker rmi <Image ID> <Image ID>

All dangling images

docker image prune

ALL images

docker rmi $(docker images -a -q)

Containers

Single container

docker rm ID_or_Name ID_or_Name

Remove all exited

docker rm $(docker ps -a -f status=exited -q)

Comments