Command to clean unused Docker container/images/volumes to get disk space | 不要なDockerコンテナ・イメージ・ボリュームを削除するコマンド

Posted: May 18, 2017

# check disk size
df -h
docker run --rm alpine df -h

# remove stopped container, unused images, unused volumes
docker rm $(docker ps -q -f 'status=exited')
docker rmi $(docker images -q -f 'dangling=true')
docker volume rm $(docker volume ls -q -f 'dangling=true')

# check disk size again
df -h
docker run --rm alpine df -h