Cleanup after Docker

I often find myself in a situation where I have several redundant Docker containers and/or images; usually after development of a new container/image and forgetting to use a flag like run --rm.

Unfortunately, Docker doesn’t provide a built-in command to cleanup after itself.

Instead, one must call Docker’s remove commands with the output of Docker’s list commands.

To remove all containers:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

To remove all ‘untagged’ images:

docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
 
1
Kudos
 
1
Kudos

Now read this

Bugs & Scrum

Bugs, those pesky errors that you didn’t foresee. As defined by Wikipedia, a bug is: … an error, flaw, failure or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in... Continue →