Skip to content

Instantly share code, notes, and snippets.

@smrchy
Created September 2, 2015 13:36
Show Gist options
  • Save smrchy/b2558c71b537ea2b2eed to your computer and use it in GitHub Desktop.
Save smrchy/b2558c71b537ea2b2eed to your computer and use it in GitHub Desktop.

Remove unused Docker containers and images

This removes all containers that are not running:

docker ps -q -a | xargs docker rm

Remove images:

docker rmi $(docker images -q -f "dangling=true")

Show memory requirements for all running containers

for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`; do docker ps | grep $line | awk '{printf $NF" "}' && echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment