Do not pull the tiny image for gateway detection when checks are disabled#11935
Open
Baqirrizvidev wants to merge 1 commit into
Open
Do not pull the tiny image for gateway detection when checks are disabled#11935Baqirrizvidev wants to merge 1 commit into
Baqirrizvidev wants to merge 1 commit into
Conversation
…bled The default gateway detection in DockerClientConfigUtils runs 'ip route' inside a tiny-image container, pulling alpine:3.17 even when checks.disable=true, although the docs state the tiny image is not required when startup checks are disabled. It also let a failed pull (e.g. restricted CI registries) crash docker host IP resolution. Skip container-based gateway detection when checks are disabled and fall back gracefully when the detection container fails. Fixes testcontainers#11241 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11241
What broke
With
TESTCONTAINERS_CHECKS_DISABLE=true, the tiny image (alpine:3.17) is still pulled in some environments, even though the docs state the tiny image is "always required (unless startup checks are disabled)".The unguarded path is default gateway detection. When the tests themselves run inside a container (
IN_A_CONTAINER, e.g. a containerized Jenkins agent) and inspecting thebridgenetwork yields no gateway,DockerClientProviderStrategy.resolveDockerHostIpAddressfalls back toDockerClientConfigUtils.getDefaultGateway(), which runsip routeinside a tiny-image container — pullingalpine:3.17regardless ofchecks.disable.This matches the log in #11241 exactly:
runInsideDockerfirst touchesResourceReaper.instance()(printing the "Ryuk has been disabled" warning) and then pulls the image, which is the reported warning → pull sequence. In the reporter's CI the registry cannot servealpine:3.17, so the pull fails — and because that failure propagates out of the lazy initializer, host IP resolution (and the whole test run) crashes.The fix
In
DockerClientConfigUtils:checks.disable=true, falling back tolocalhost(users who need a specific address in such setups can still setTESTCONTAINERS_HOST_OVERRIDE). This honors the documented contract that the tiny image is not required when checks are disabled.Added a unit test asserting that gateway detection does not touch Docker when checks are disabled.
🤖 Generated with Claude Code