Repository navigation
[Repo Assist] fix(run_containerized): skip port mapping validation for host-networked containers - #7684
Merged
lpcox merged 2 commits intoJun 17, 2026
Conversation
…ed containers
When a container is started with --network host, Docker sets
NetworkSettings.Ports={} because published ports are discarded.
The existing validate_port_mapping check inspects NetworkSettings.Ports
and fails with "Port N is not exposed from the container", making it
impossible to use the gateway image with host networking even when a
-p flag is present.
Fix: inspect HostConfig.NetworkMode before the port mapping check.
If the value is "host", skip the NetworkSettings.Ports validation
and log an informational message instead. Bridge-networked containers
are unaffected.
Closes #7647
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the containerized startup validation script to correctly handle Docker containers running with --network host, where Docker discards published port mappings and leaves .NetworkSettings.Ports empty.
Changes:
- Detect
HostConfig.NetworkMode=hostinvalidate_port_mappingand skip port-mapping validation in that case. - Add explanatory comments and an informational log message for host-networked containers.
Show a summary per file
| File | Description |
|---|---|
| run_containerized.sh | Skips port-mapping validation for host-networked containers to avoid false startup failures. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lpcox
deleted the
repo-assist/fix-host-network-validation-7647-ac55ac2c319c2393
branch
June 17, 2026 15:02
This was referenced Jun 18, 2026
github-actions Bot
added a commit
that referenced
this pull request
Sep 28, 2026
… --validate-env Closes #14053 Root cause: run_containerized.sh's validate_port_mapping already skips port-mapping validation when a container's HostConfig.NetworkMode is "host" (fixed in #7684 for #7647), but the Go validator that run_containerized.sh now delegates to via --validate-env (ValidateContainerizedEnvironmentForRuntime) never got the same exception. Docker discards published port mappings for --network host containers, so NetworkSettings.Ports is always empty and CheckPortMapping always fails, regressing #7647 for anyone running the gateway with --validate-env under host networking. Fix: add sys.IsHostNetworkMode(containerID), which inspects HostConfig.NetworkMode the same way run_containerized.sh's bash fix does, and skip the NetworkSettings.Ports check in ValidateContainerizedEnvironmentForRuntime when host networking is detected, treating the port as satisfied. Bridge-networked containers are unaffected. Trade-offs: matches the existing bash-side exception exactly, so no new security surface; a failure to determine the network mode falls back to running the original port-mapping check with a warning instead of erroring outright. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lpcox
added a commit
that referenced
this pull request
Sep 28, 2026
… containers in --validate-env (#14065) 🤖 *This PR is from Repo Assist, an automated AI assistant for this repository.* Closes #14053 ## Root Cause `run_containerized.sh`'s `validate_port_mapping` already skips port-mapping validation when a container's `HostConfig.NetworkMode` is `"host"` (fixed in #7684 for #7647), but the Go validator that `run_containerized.sh` now delegates to via `--validate-env` (`ValidateContainerizedEnvironmentForRuntime` in `internal/config/validation_env.go`) never got the same exception. Docker discards published port mappings for `--network host` containers, so `NetworkSettings.Ports` is always empty and `CheckPortMapping` always fails — regressing #7647 for anyone using `--validate-env` under host networking, exactly as reported in #14053. ## Fix - Added `sys.IsHostNetworkMode(containerID)` in `internal/sys/docker.go`, which inspects `HostConfig.NetworkMode` the same way `run_containerized.sh`'s bash fix does. - `ValidateContainerizedEnvironmentForRuntime` now checks host networking first and skips the `NetworkSettings.Ports` validation when detected, treating the port requirement as satisfied (matching the bash-side behavior). Bridge-networked containers are completely unaffected. - If the network-mode check itself fails (e.g., docker inspect error), we fall back to running the original port-mapping check and surface a warning, so we never silently skip validation when we can't determine the mode. ## Trade-offs - No security impact: this exactly mirrors an existing, already-shipped bash-side exception; it does not relax any check for bridge-networked containers. - No new dependencies. ## Test Status ✅ **Build**: `go build ./...` passes ✅ **Unit tests**: added `TestIsHostNetworkMode` in `internal/sys/docker_test.go` (mirrors existing `TestCheckPortMapping` coverage: empty ID, invalid ID, unreachable docker socket cases); `go test ./internal/sys/... ./internal/config/...` passes ✅ **make agent-finished**: full pipeline (format, build, lint, all Go + Rust guard tests) passes clean > [!WARNING] > <details> > <summary>Firewall blocked 4 domains</summary> > > The following domains were blocked by the firewall during workflow execution: > > - `example.com` > - `nonexistent.local` > - `slow.example.com` > - `thishostdoesnotexist12345.com` > > To allow these domains, add them to the `network.allowed` list in your workflow frontmatter: > > ```yaml > network: > allowed: > - defaults > - "example.com" > - "nonexistent.local" > - "slow.example.com" > - "thishostdoesnotexist12345.com" > ``` > > See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information. > > </details> > Generated by [Repo Assist](https://github.com/github/gh-aw-mcpg/actions/runs/36424956675) · copilot · auto · 370.9 AIC · ⊞ 18.7K · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+repo-assist%22&type=pullrequests) > <sub>Comment <em>/repo-assist</em> to run again</sub> > <details> <summary><sub>Add this agentic workflow to your repo</sub></summary> To install this agentic workflow, run ``` gh aw add githubnext/agentics@851905c ``` </details> <!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, model: auto, id: 36424956675, workflow_id: repo-assist, run: https://github.com/github/gh-aw-mcpg/actions/runs/36424956675 --> <!-- gh-aw-workflow-id: repo-assist --> <!-- gh-aw-workflow-call-id: github/gh-aw-mcpg/repo-assist -->
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.
🤖 This PR is from Repo Assist, an automated AI assistant for this repository.
Root Cause
When a container is started with
--network host, Docker discards published port mappings and setsNetworkSettings.Ports={}. The existingvalidate_port_mappingfunction checks.NetworkSettings.Portsfor the port key and aHostPortvalue. Both checks fail for host-networked containers — even when-pflags are present — causing the gateway to exit with:This is environment-dependent: on Docker Desktop the
get_container_idcall often fails, so the entire validation block is skipped and the issue is invisible. On Linux DinD runners the container ID is discoverable, so the bad validation fires.Fix
Add a
HostConfig.NetworkModecheck at the top ofvalidate_port_mapping. If the mode ishost, log an informational message and return early — ports are directly accessible on the host interface and no mapping validation is needed. Bridge-networked containers are completely unaffected.Trade-offs
validate_container_configchecks that inspectNetworkSettingsfor host-networked containers if similar issues arise.Closes #7647
Test Status
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run