List all docker containers:

[shell]docker ps -a[/shell]

List docker container names:

[shell]docker ps –format “{{.Names}}”[/shell]

List docker images names:

[shell]docker images -a[/shell]

Stop all running containers:

[shell]docker stop $(docker ps -aq)[/shell]


 

Get docker space commands.

1.1 Get diff size

[shell]du -sh /var/lib/docker/aufs/diff/[/shell]

 


 

NOTE: Anything previous to 1.13 does not use garbage collecting. If docker runs out of space, try the commands below.

1.1 Remove exited containers:

[shell]docker ps –filter =exited -aq \ | xargs -r docker rm -v[/shell]

1.2 Remove unused docker images:

[shell]docker rmi $(docker images | grep “none”\ | awk -F’ ‘ ‘{print $3}’)[/shell]

1.2a Remove orphaned docker volumes

[shell]docker volume rm \ $(docker volume ls -qf dangling=true)[/shell]

1.3 Remove dead containers:

[shell]docker ps –filter status=dead -aq \ | xargs -r docker rm -v[/shell]

1.4 Remove intermediate containers generated during docker build:

[shell]docker ps -a | grep “/bin/sh -c” | awk -F’ ‘ ‘{print $1}’ | xargs docker rm[/shell]

1.5 Remove Image with <none> string:

[shell]echo “Remove docker images with <none> string”
if docker images | grep none | tee; then
docker rmi $(docker images | grep “none” | awk -F’ ‘ ‘{print $3}’) | tee
fi[/shell]

Docker Garbage Collection Version 1.13.0:

[shell]docker system prune[/shell]