Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Docker useful commands
# Clean unused images
docker image prune
# Clean up dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Delete images with that maches criteria
docker images | grep $name_of_your_image | awk '{print $1}' | xargs docker rmi
# stop containers from a specific grep criteria
docker ps -a | grep $name_of_your_image | awk '{print $1}' | xargs docker stop
# rm containers from a specific grep criteria
docker ps -a | grep $name_of_your_image | awk '{print $1}' | xargs docker rm
# exited containers
docker ps -a -f "exited=-1"
# delete non-persistent containers (aka web)
docker rm $(docker ps -a | grep _run_ | cut -d' ' -f1)
# delete unused containers
docker rm $(docker ps -a | grep Exited | cut -d' ' -f1)
# enter in the first container
docker exec -it `docker ps -a --no-trunc -q | head -n 1` bash
# create the docker host machine with 100GB of disk space.
docker-machine -D create -d virtualbox --virtualbox-disk-size "100000" default
# convert your running docker machine to use NFS instead of vboxfs
# install https://github.com/adlogix/docker-machine-nfs
docker-machine-nfs default
# docker pool clean up
docker ps -qa | xargs docker inspect --format='{{ .State.Pid }}' | xargs -IZ fstrim /proc/Z/root/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment