Docker 다이어트

사용하지 않는 이미지, 컨테이너, 볼륨, 네트워크 등 정리

Prune

$ docker image prune
$ docker container prune
$ docker volume prune
$ docker network prune

Workaround

Image

$ docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
$ docker rmi $(docker images | grep "none" | awk '/ / { print $3 }')

Container

$ docker rm $(docker ps -qa --no-trunc --filter "status=exited")

Volume

$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm

Network

$ docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')