✦ For everyone, free.

Practical knowledge for real and everyday life

Home

19.3 System CLI Commands

A focused guide to System CLI Commands, connecting core concepts with practical Docker and container operations.

Docker system CLI commands operate at the level of the entire Docker installation rather than individual containers, images, or volumes. They provide visibility into disk usage, allow bulk cleanup of unused resources, and expose daemon-level information. These commands are grouped under the docker system subcommand namespace.

docker system df

docker system df reports disk usage across all Docker resource types on the host:

docker system df

Sample output:

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          12        4         3.2GB     1.8GB (56%)
Containers      8         2         245MB     198MB (80%)
Local Volumes   5         2         1.1GB     650MB (59%)
Build Cache     47        0         892MB     892MB
  • TOTAL: Total number of resources of that type.
  • ACTIVE: Number currently in use (images referenced by running containers, volumes mounted by running containers).
  • SIZE: Total disk space consumed.
  • RECLAIMABLE: Space that can be freed by pruning unused resources.

For a per-resource breakdown:

docker system df -v

This shows each image, container, and volume with its individual size and whether it is reclaimable.

docker system prune

docker system prune removes all unused Docker resources in a single command:

docker system prune

By default this removes:

  • All stopped containers.
  • All networks not used by at least one container.
  • All dangling images (images not tagged and not referenced by any container).
  • All build cache entries.

Docker prompts for confirmation before proceeding and then prints a summary of deleted resources and reclaimed space.

To skip the confirmation:

docker system prune --force

To also include unused volumes (both named and anonymous that are not referenced by any container):

docker system prune --volumes

To remove all unused images (not just dangling ones, but also any tagged images not used by running containers):

docker system prune --all

Combining flags:

docker system prune --all --volumes --force

This is the most aggressive cleanup option and frees the maximum possible disk space. Use it only on hosts where you are certain no cached images or volumes need to be retained.

docker system info

docker system info (also invokable as docker info) displays detailed information about the Docker daemon and the host system:

docker system info

The output covers:

  • Containers: Total count with breakdowns by running, paused, and stopped.
  • Images: Total number of images.
  • Storage Driver: The filesystem driver Docker uses for container layers (e.g., overlay2, devicemapper, btrfs).
  • Logging Driver: The default logging driver for containers.
  • Cgroup Driver: How resource limits are enforced (cgroupfs or systemd).
  • Plugins: Available volume, network, and authorization plugins.
  • Swarm: Whether Swarm mode is active and the current node role.
  • Runtimes: Available container runtimes (runc and others).
  • Docker Root Dir: The path where Docker stores all its data on the host filesystem.
  • HTTP Proxy / HTTPS Proxy: Proxy settings in effect.
  • Registry: The default image registry (typically https://index.docker.io/v1/).
  • Labels: Host-level labels set on the daemon.
  • CPUs / Total Memory: Host resources available to containers.
  • Operating System / Kernel Version: Host OS details.
  • Server Version: Docker daemon version.
docker system info --format "{{.DockerRootDir}}"

The --format flag accepts Go templates to extract specific fields.

docker system events

docker system events streams real-time events from the Docker daemon:

docker system events

Events include container lifecycle transitions (create, start, stop, die, destroy), image pulls, volume mounts, network connections, and more. Each event line includes a timestamp, the event type, the resource ID, and the action.

To filter events by type:

docker system events --filter type=container
docker system events --filter type=image
docker system events --filter type=volume
docker system events --filter type=network

To filter by a specific action:

docker system events --filter event=die
docker system events --filter event=start

To filter by container name or ID:

docker system events --filter container=my_container

To see events from a specific time range rather than streaming live:

docker system events --since "2024-03-15T10:00:00" --until "2024-03-15T11:00:00"

Relative time expressions are also supported:

docker system events --since "1h"

Relationship Between System Commands and Resource-Specific Commands

The docker system commands provide host-wide operations that complement the resource-specific prune commands:

Resource-Specificdocker system equivalent
docker container prunePart of docker system prune
docker image prunePart of docker system prune
docker volume prunePart of docker system prune --volumes
docker network prunePart of docker system prune

Using docker system prune is a shortcut to running all of the above in sequence. The resource-specific commands offer more granular control when you want to prune only one resource type while leaving others intact.

Practical Usage Patterns

Check how much space can be reclaimed before pruning:

docker system df

Remove everything unused without prompts (CI/CD cleanup):

docker system prune --all --volumes --force

Monitor what is happening on the daemon in real time:

docker system events --filter type=container

Find the Docker data directory to understand where space is being used:

docker system info --format "{{.DockerRootDir}}"

Stream all die events (useful for detecting crash loops):

docker system events --filter event=die

Content in this section