You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Enhancement]: Allow configuring ImageFromDockerfile to build without layer cache by default #12091
ImageFromDockerfile should be configurable to build without the layer cache by default, through a configuration property read by TestcontainersConfiguration like the others:
# ~/.testcontainers.properties or classpath testcontainers.propertiesimagefromdockerfile.nocache=true
or TESTCONTAINERS_IMAGEFROMDOCKERFILE_NOCACHE=true.
When set, ImageFromDockerfile.configure calls buildImageCmd.withNoCache(true) before running the user's buildImageCmdModifiers, so a call site can still turn the cache back on.
The default stays as it is today (cache on).
Limitations of the current implementation
With deleteOnExit (the default), an ImageFromDockerfile gets the session labels, and Ryuk removes it when the session ends.
Those labels are only on the final image. Its intermediate layers come from the daemon's build cache, so they are shared with every other session that builds the same Dockerfile on the same daemon.
When one session ends, Ryuk removes its image and the untagged parent layers go with it. If another session is building the same Dockerfile at that moment, its build can fail because the cached layers it is using no longer exist.
This happens on CI agents that run several builds of the same project on one Docker daemon.
The only way to avoid it today is to disable the cache on every ImageFromDockerfile:
This has to be repeated at every call site. If one is forgotten, you get a random failure that only shows up when builds run at the same time.
It also can't reach images built inside Testcontainers modules and libraries.
With the property, a CI environment sets it once, on the agent or in the project's testcontainers.properties, and every ImageFromDockerfile is covered.
Activity