feat(docker): docker_network config field for sandbox network attachment - #16359
Closed
sasha-id wants to merge 1 commit into
Closed
feat(docker): docker_network config field for sandbox network attachment#16359sasha-id wants to merge 1 commit into
sasha-id wants to merge 1 commit into
Conversation
Widen DockerEnvironment's `network` parameter from bool to bool | str.
Allows attaching the sandbox to a named user-defined docker network
(e.g. for accessing compose-deployed sibling services like databases,
MCP servers, or monitoring stacks via container DNS).
- True (default): no --network flag — docker default bridge (current behavior)
- False: --network=none (current behavior preserved)
- str: --network=<name> (new — joins the specified network)
Schema addition in terminal: config:
terminal:
backend: docker
docker_network: my-net # new — string
Existing configs without `docker_network` retain identical behavior.
sasha-id
force-pushed
the
feature/docker-network-config-field-upstream
branch
from
May 4, 2026 16:16
2f310bd to
254ed3f
Compare
Collaborator
|
Likely duplicate of #4922 — same feature: wiring docker_network config through docker backend to docker run --network. |
1 similar comment
Collaborator
|
Likely duplicate of #4922 — same feature: wiring docker_network config through docker backend to docker run --network. |
Contributor
Author
|
Closing — upstream's |
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.
What does this PR do?
Adds a
docker_networkfield to theterminal:config schema, exposed by wideningDockerEnvironment.networkfrombooltobool | str. Lets the sandbox container attach to a user-defined docker network so it can reach compose-deployed sibling services (databases, MCP servers, monitoring) by container DNS — a common deployment pattern that's currently unreachable without heavyweight workarounds (HERMES_DOCKER_BINARYwrapper, iptables, or tailscale routing).Specifically narrower than a generic
docker_extra_argsknob — single-purpose, no privilege-escalation surface (no way to bypass_SECURITY_ARGS).Related Issue
No prior issue — opening speculatively. Happy to file one and convert if maintainers prefer that flow.
Type of Change
Changes Made
tools/environments/docker.py: signaturenetwork: bool→network: bool | str; body conditional rewritten to handle three cases (is False→--network=none,isinstance(_, str)→--network=<value>, else default).tools/terminal_tool.py: extractdocker_networkfromcontainer_config(defaultTrue) in_create_environment; passnetwork=docker_networkto_DockerEnvironment; add"docker_network": config.get("docker_network", True)to thecontainer_configbuilder so the YAML field actually reaches the call site.cli-config.yaml.example: document the new field under the Docker backend section, alongside the existingdocker_forward_env/docker_mount_cwd_to_workspaceexamples.tests/tools/test_docker_environment.py: 3 new constructor tests (network=Trueomits flag,network=Falseadds--network=none,network="name"adds--network=name).tests/tools/test_parse_env_var.py: 2 new threading tests (docker_networkextracted fromcontainer_configreaches_DockerEnvironment; absence defaults toTrue).How to Test
pytest tests/tools/test_docker_environment.py tests/tools/test_parse_env_var.py -v— all green (5 new + pre-existing 31 = 36 passed).~/.hermes/config.yaml, set:my-named-net(e.g.docker run --rm --network=my-named-net --name sibling alpine sleep 3600). Then in a hermes session:getent hosts siblingresolves;curl http://sibling:<port>succeeds.docker_networkruns identically (no--networkflag — Docker's default bridge).Checklist
Code
pytest tests/tools/test_docker_environment.py tests/tools/test_parse_env_var.py -qand all tests pass (36 passed, including the 5 new)Documentation & Housekeeping
cli-config.yaml.example+ behavior described in commit body)cli-config.yaml.examplefor the new config key--network=<name>flag is identical across Docker on Linux/macOS/Windows; no platform-specific code paths touchedNotes for reviewer
One subtle behavior change worth disclosing: the body conditional changed from
if not network:toif network is False: ... elif isinstance(network, str): .... Previously any falsy non-bool (None,"",0) would trigger--network=none. Now only literalFalsedoes. In practice the only caller iscc.get("docker_network", True)which returnsTrue | False | str, so users with existing configs see no change. Mentioning explicitly so it doesn't surprise future spelunkers.