Steve Hostettler

JEE and test automation

Cleaning Intermediate Docker Images

| Comments

I recently started to use Docker. It is a great tool that significantly increases developer’s productivity. However, I regularly encounter disk space problems when developing new images. Indeed, I sometimes end up with dangling images and containers. Hereafter, a simple script that cleans up most of them.

1
2
3
4
#!/bin/bash
docker rmi -f `docker images | grep "^<none>" | cut -c41-52`
docker rmi $(docker images -q -f dangling=true)
docker rm -v $(echo $(docker ps -q --no-trunc) $(docker ps -a -q --no-trunc) | sed 's|\s|\n|g'  | sort | uniq -u)

Comments