What I learned today

What I learned today

Personal blog about programming and all that stuff

21 May 2019

How to remove all Docker images at once

Somtimes it is necessary to remove all Docker images or containers on your machine. Here is how it goes. It’s pretty easy.

Container ship

Problem: You use Docker. You have created a bunch of containers and images over time that you want to get rid of all at once.

Solution

Attention: This will delete all your images or containers. It is not possible to restore them.

#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)