How to configure maximum cache layers when using Docker BuildKit?

133 views Asked by At

I have allocated 500GB to my docker builder machine, but I can see that /var/lib/docker never goes above 50GB. The number is too round to be random.

The Docker configuration does not have much information:

$ cat /etc/docker/daemon.json
{
  "features": {
    "buildkit": true
  }
}

There appears to be no BuildKit specific configuration on my VM (Debian).

There is a documentation page for garbage collection, but it does not mention any defaults for BuildKit. Does this mean that Docker daemon defaults apply?

I have tried adjusting defaultKeepStorage to 450GB, but the /var/lib/docker remains at around 50GB.

For context, I am using BuildKit:

$ docker buildx create --name=container --driver=docker-container --use
$ docker buildx build ...

Here is the description of the builder instance:

root@github-action-runner-docker-builder:/home/gajus# docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT             PLATFORMS
default * docker
  default default         running v0.11.6+616c3f613b54 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
root@github-action-runner-docker-builder:/home/gajus# docker buildx inspect default
Name:   default
Driver: docker

Nodes:
Name:      default
Endpoint:  default
Status:    running
Buildkit:  v0.11.6+616c3f613b54
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
Labels:
 org.mobyproject.buildkit.worker.moby.host-gateway-ip: 172.17.0.1
GC Policy rule#0:
 All:           false
 Filters:       type==source.local,type==exec.cachemount,type==source.git.checkout
 Keep Duration: 172.8µs
 Keep Bytes:    62.18GiB
GC Policy rule#1:
 All:           false
 Keep Duration: 5.184ms
 Keep Bytes:    450GiB
GC Policy rule#2:
 All:        false
 Keep Bytes: 450GiB
GC Policy rule#3:
 All:        true
 Keep Bytes: 450GiB
0

There are 0 answers