Yes, it is somewhat vague in docker 20.10.5. Could use a pull request or two to update documentation.
- The
docker
driver cache uses the same storage driver as used for image layers. Metadata is stored in databases at/var/lib/docker/buildkit
. When docker usesoverlay2
storage driver, the layer is in/var/lib/docker/overlay2/<ID>/diff/
. For<ID>
, see below./var/lib/docker
can vary depending ondata-root
in yourdockerd
configuration. Builders usingdocker-container
orkubernetes
driver keeps the data on a volume. docker buildx [--builder name] du --verbose
lists build cache. You can also inspect the docker driver caches fromdocker system df -v --format '{{ .BuildCache | json }}'
. The cache typeexec.cachemount
is theRUN --mount type=cache
. You can find the layer using theID
, which is not the same as used in--mount id
. The mount type is implemented by buildkit, so thedocker run --mount
does not recognize it. To get rid of it eitherdocker buildx prune
ordocker build --no-cache
.- The cache key is the value from
id=
.id
defaults to value oftarget
. You need to specifyid
when you need different cache at the sametarget
. - Yes. They are the same cache regardless of the
target
or Dockerfile. Different builders have their own caches, which keeps for example caches for different architectures separate.