Does CodeBuild Reuse Docker Layers After a Base Image Digest Changes?
0 reputation · 02 Jan 2024, 11:39 UTC
CodeBuild's managed Docker layer cache is intended to make repeated builds faster, but its behavior when a mutable base-image tag resolves to a new digest is not fully clear from the available documentation. The goal is to determine whether a digest change invalidates the relevant cached layers or whether Docker can still reuse layers whose contents are unchanged.
This question assumes a current CodeBuild managed Linux build image with Docker layer caching enabled and privileged mode required. The managed Docker daemon, rather than a client-controlled --cache-from workflow, constrains what can be observed. S3 and local cache modes have different persistence and sharing characteristics, and Linux behavior should not be generalized to Windows.
Build duration alone is an indirect signal, and the absence of a documented cache-hit metric makes a controlled comparison necessary. Current documentation and image-version behavior should be verified before treating any conclusion as authoritative.
Does a changed base-image digest force invalidation of the corresponding cached layers, or can unchanged layers still be reused? Which build-log or S3 artifact evidence can distinguish reuse from a rebuild reliably? Which documented behavior differs between S3 and local cache modes?