# Working with Docker Images from the command line

> Learn how to work with Docker images from the command line, listing them with docker images and removing images and dangling ones with docker rmi and prune.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-07-17 | Topics: [Docker](https://flaviocopes.com/tags/docker/) | Canonical: https://flaviocopes.com/docker-images-command-line/

You can list all the images you have downloaded or installed using the 

```
docker images -a
```

command:

![Terminal output showing docker images -a command listing all Docker images with repository, tag, image ID, creation time and size](https://flaviocopes.com/images/docker-images-command-line/Screen_Shot_2020-07-05_at_11.44.47.png)

You can remove an image with `docker rmi` command, passing the name of the image you want to remove. This will remove the image.

![Terminal output showing docker rmi examplenode command with multiple deletion confirmation messages for image layers](https://flaviocopes.com/images/docker-images-command-line/Screen_Shot_2020-07-05_at_11.45.40.png)

Sometimes when testing and developing, some images become dangling, which means untagged images. They can always be safely removed to free disk space.

Running `docker images -f dangling=true` will list them:

![Terminal output showing docker images -f dangling=true command listing three untagged Docker images with their IDs and sizes](https://flaviocopes.com/images/docker-images-command-line/Screen_Shot_2020-07-05_at_14.49.26.png)

And you can clear them with `docker rmi $(docker images -f dangling=true -q)`. This command will only eliminate dangling images used in containers, even if not currently running.

`docker system prune -a`, which is also a commonly used way to remove images, will also remove images not referenced by any container, which might remove images you might want to keep, even just to rollback to previous versions of an image.

You can also remove all images using `docker rmi $(docker images -a -q)` if you want to clean everything, which might be nice during your first tests and experiments with Docker.
