# How to Remove Old and Unused Docker Images?

Since the docker version 1.13 you can use the `docker prune` command to remove all dangling data such as containers stopped, volumes without containers, and images with no containers.

To remove dangling docker images you execute the following command:

```bash
docker image prune
```

You can also add an optional `-a` option to the command to remove all dangling as unused images. Unused, in this case, means unreferenced by another container

```bash
docker image prune -a
```

## Docker before version 1.13

To remove dangling and unused docker images, you can use the following commands:

```bash
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
```
