Clean up docker images (Commandline)

Have you been exploring different docker images?

Have you noticed your available disk space reduced significantly after a while?

It might be due to your unwanted (unused) images sitting in your hard disk. It’s time to clean it up

First of all, to find out what are the images you have on your system, use the command

>> docker images
REPOSITORY                        TAG       IMAGE ID       CREATED        SIZE
mariadb                           latest    2cd1259c6b0b   6 days ago     403MB
dpage/pgadmin4                    latest    668d06fdece7   7 days ago     527MB
<none>                            <none>    63fd06fdece7   14 days ago    552MB
eclipse-mosquitto                 latest    a421387ae63e   2 weeks ago    13.3MB

There can be multiple reasons having unwanted images after a while:

  • Images without any containers spun up (or removed)
  • Older versions of images
  • and many other reasons

You can remove images one at a time with the following command

>> docker rmi <image_id or image:tag>

If you want to remove all unused images, use the following command

>> docker image prune -a

About: author