Skip to main content

Cache

Dagger caches two types of data:

  1. Layers: This refers to build instructions and the results of some API calls.
  2. Volumes: This refers to the contents of a Dagger filesystem volume and is persisted across Dagger Engine sessions.

Cache inspection

  • Show all the cache entry metadata:

    dagger query <<EOF
    {
    engine {
    localCache {
    entrySet {
    entries {
    description
    diskSpaceBytes
    }
    }
    }
    }
    }
    EOF
  • Show high level summaries of cache usage:

    dagger query <<EOF
    {
    engine {
    localCache {
    entrySet {
    entryCount
    diskSpaceBytes
    }
    }
    }
    }
    EOF

Garbage collection

The cache garbage collector runs in the background of the dagger engine, looking for unused layers and artifacts, and clears them up once they exceed the storage allowed by the cache policy.

The default cache policy attempts to keep the long-term cache storage under 75% of the total disk, while also ensuring that at least 20% of the disk remains free for other applications and tools.

The cache policy can be manually configured by editing the engine.toml file in the engine (which uses BuildKit's syntax config). See the Custom Runner docs for more information.

Manual pruning

To manually free up disk space used by the cache, use the following command:

dagger query <<EOF
{
engine {
localCache {
prune
}
}
}
EOF