Docker CLI scripts

Using Docker

This post contains some most often used CLI tricks to manage Docker CLI

List all running containers

1
docker ps -a 

Remove all running containers

1
docker ps -a --format {{.ID}} | xargs docker rm -f

Clean the docker

There’s following steps to free up the space in your computer

Clean all images

1
docker images --format {{.ID}} | xargs docker image rm

Clear all volumes

1
docker volume ls --format '\''{{.Name}}'\'' | xargs docker volume rm

Full system clean up

If you are running out of system resources you could run and clean all docker resources.

Beware this will remove everything from your computer and it is not reversable.

1
docker system prune -a