# docker image prune: Remove Unused Images

> How docker image prune works: removing dangling or all unused images, the -a flag, age filters, and reclaiming disk safely in CI.

Source: https://latchkey.dev/learn/command-reference/docker-image-prune-command  
Updated: 2026-06-25

Remove dangling - or all unused - images to free disk.

docker image prune removes images that are not referenced. This page covers dangling vs all-unused removal and the filters that make it safe in CI.

## What it does

By default docker image prune removes only dangling images (untagged layers). With -a it removes every image not used by an existing container, which is a much bigger reclaim.

## Common usage

```Terminal
docker image prune -f
docker image prune -af                  # all unused images
docker image prune -af --filter "until=24h"
```

## Common errors in CI

Without -f it prompts and hangs in CI - always pass -f. -af is more aggressive than people expect: it removes any image not currently used by a container, so a base image you will need next step gets deleted and re-pulled. Use --filter "until=" to keep recent images, or scope cleanup to between unrelated jobs.

## FAQ

### docker image prune: Remove Unused Images?

docker image prune removes images that are not referenced. This page covers dangling vs all-unused removal and the filters that make it safe in CI.

### What it does?

By default docker image prune removes only dangling images (untagged layers). With -a it removes every image not used by an existing container, which is a much bigger reclaim.

### Common errors in CI?

Without -f it prompts and hangs in CI - always pass -f. -af is more aggressive than people expect: it removes any image not currently used by a container, so a base image you will need next step gets deleted and re-pulled. Use --filter "until=" to keep recent images, or scope cleanup to between unrelated jobs.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
