Docker clean commands

| Comments

When you start to use Docker, at some point there will be a question - where is all my space. Most of it is occupied by containers, images and dangling volumes.

An easy way to clean is to use Docker garbage collection by Spotify and docker volume rm commands. I have an alias for this.

alias docker-gc='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /etc:/etc -e GRACE_PERIOD_SECONDS=172800 spotify/docker-gc && docker volume rm $(docker volume ls -qf dangling=true)'

On mac sometimes it’s easier to remove all, for this you need to remove Docker.qcow2 in the ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux folder. You can find this path in the Docker -> Preferences -> Advanced dialog.

« 2/2