Skip to content

Add a pool option that selects the runner network - #22

Merged
clroot merged 1 commit into
mainfrom
pool-network
Nov 9, 2026
Merged

clroot merged 1 commit into
mainfrom
pool-network

Conversation

@clroot

@clroot clroot commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Problem

#20 added JAVA_TOOL_OPTIONS=-Djava.net.preferIPv4Stack=true as the fix for JVM builds on Docker Desktop host-network runners. Gradle's worker daemons do not inherit the build's environment variables, so it is not enough. ktlint, for example, runs in those workers. A quality job in another repository still failed on runKtlintCheckOverKotlinScripts: Could not connect to server [... addresses:[/127.0.0.1]], Connection refused.

To check which processes got the variable, a JVM log option was added to it. With it set, the Gradle client and daemon got it, but the four worker daemons did not.

Change

  • Pool option network = "host" | "bridge", or pool add --network host|bridge.
    • Unset keeps the previous behavior: host for docker_socket pools, Docker's default bridge otherwise.
    • Only a change of the effective network starts a new runner generation. Writing out the default does not replace runners.
  • docs/platforms.md: the Docker Desktop JVM section now recommends a bridge pool with TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal. This replaces the incorrect JAVA_TOOL_OPTIONS advice.
  • docs/operations.md, config.example.toml: document the option and what bridge pools give up: services: through localhost.
  • tests/docker-socket.sh: RUNNER_NETWORK=bridge checks a bridge pool.

Verification

On Docker Desktop 4.95.0 (WSL2), with the Docker socket mounted:

Runner network Settings ktlint (Gradle workers) Testcontainers MariaDB test
host JAVA_TOOL_OPTIONS, TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 fails passes
bridge none passes fails (Ryuk at 172.17.0.1)
bridge TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal passes passes
  • cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked: pass. Adds 3 tests: config defaults and roundtrip, container args, runner generation.
  • tests/entrypoint.sh, tests/docker-socket.sh (host and RUNNER_NETWORK=bridge), cargo test --locked docker_ -- --ignored: pass.

🤖 Generated with Claude Code

Docker socket pools always used the host network. On Docker Desktop 4.95.0
(WSL2 backend) a JVM there cannot connect to 127.0.0.1 in the same
runner, and JAVA_TOOL_OPTIONS=-Djava.net.preferIPv4Stack=true (#20) only
helps part of a build: Gradle starts worker daemons, which ktlint uses,
without the build's environment, so they still fail to reach the daemon.

network = "host" | "bridge" (or pool add --network) now picks the
network for a pool's runner containers. Unset keeps the previous
behavior: host for Docker socket pools, Docker's default bridge
otherwise. Only a change of the effective network starts a new runner
generation, so writing out the default does not replace runners.

docs/platforms.md now recommends a bridge pool with
TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal for JVM builds on
Docker Desktop, replacing the JAVA_TOOL_OPTIONS advice.
tests/docker-socket.sh takes RUNNER_NETWORK to check a bridge pool.

Verification: cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings,
cargo test --locked, tests/entrypoint.sh, tests/docker-socket.sh with host
and bridge, cargo test --locked docker_ -- --ignored. On the same Docker
Desktop, a Gradle build with ktlint workers, Kotlin compilation and a
Testcontainers MariaDB test passed in a bridge container with the socket
mounted and the override set.
@clroot clroot mentioned this pull request Nov 9, 2026
@clroot
clroot merged commit a4e8ddf into main Nov 9, 2026
8 of 9 checks passed
@clroot
clroot deleted the pool-network branch November 9, 2026 07:44
This was referenced Nov 9, 2026
clroot added a commit that referenced this pull request Nov 9, 2026
Adds two pool options: env (#20) passes environment variables to a
pool's runner containers and their jobs, and network (#22) runs a
Docker socket pool on Docker's bridge network instead of the host
network. Together they let JVM builds with Testcontainers run on Docker
Desktop, where a host-network runner cannot reach 127.0.0.1 from Java.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant