docker system prune will delete ALL dangling data (i.e. In order: containers stopped, volumes without containers and images with no containers). Even unused data, with -a option.

You also have:

For unused images, use docker image prune -a (for removing dangling and ununsed images).
Warning: ‘unused‘ means “images not referenced by any container”: be careful before using -a.

As illustrated in A L‘s answerdocker system prune --all will remove all unused images not just dangling ones… which can be a bit too much.

Combining docker xxx prune with the --filter option can be a great way to limit the pruning (docker SDK API 1.28 minimum, so docker 17.04+)

The currently supported filters are:

  • until (<timestamp>) – only remove containers, images, and networks created before given timestamp
  • label (label=<key>label=<key>=<value>label!=<key>, or label!=<key>=<value>) – only remove containers, images, networks, and volumes with (or without, in case label!=... is used) the specified labels.

See “Prune images” for an example.