Docker cleanup

Quick post about docker.
What is docker?
Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment. (https://www.docker.com/what-docker)

Docker is gaining popularity and some clients are using it in production. As a method to package and deploy self-sufficient applications in primarily stateless Linux containers it allows a consistent platform that in itself is quite simple for Ops to look after, and we don't need to know the inner workings of the application we are deploying.

However when writing and building Docker images, my virtual machine (local Docker host) starts looking a bit littered with docker containers and images. So here are a few commands to tidy up.

Kill running containers:

docker kill $(docker ps -qa)

Delete all containers (and their associated volumes):

docker rm -v $(docker ps -qa)

Remove all images:

docker rmi $(docker images -q)

(Thanks to Mike O'Conner)