[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>
This was referenced Jun 18, 2026
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