Disk usage using df command:
$ docker system df
Returns something like this,
TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 35 6 8.332GB 7.364GB (88%) Containers 12 12 417.6MB 0B (0%) Local Volumes 67 2 2.828GB 2.828GB (100%) Build Cache 0B 0B Notice the Reclaimable this is the size you can recover, it is calculated by subtracting the size of active images from the size of total images.
Real time events using events command:
$ docker system events
Returns the list of real time events from the server, based on Docker object types.
Formatting output
$ docker system events --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'
or simply format the output as JSON
$ docker system events --format '{{json .}}'
System-wide info using info command:
Another cool command to get all the system related information is the info command. You will be amazed to see the amount of info you can get.
$ docker system info
Remove unused data using prune command:
Now that we have all the info we need, its cleanup time, but beware against using this command half asleep.
$ docker system prune
WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - all build cache Are you sure you want to continue? [y/N] Further we can remove exactly what we want, using any of the following commands, feast you eyes ladies and gents.
$ docker system prune -a --network
$ docker image prune
$ docker container prune
$ docker volume prune
$ docker network prune