Skip to content

docker: note that dind with --network=host clobbers the host's iptables chains - #2722

Merged
tianon merged 2 commits into
docker-library:masterfrom
ladydd:dind-host-network-note
Nov 25, 2026
Merged

tianon merged 2 commits into
docker-library:masterfrom
ladydd:dind-host-network-note

Conversation

@ladydd

@ladydd ladydd commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Ran into this with a CI runner image based on dind that someone briefly started with host networking. Every compose app on a user-defined bridge network on that host quietly lost outbound access, and published ports broke once those containers were restarted. It took a while to connect it back to the runner.

The inner daemon calls removeIPChains() on startup (daemon/libnetwork/drivers/bridge/internal/iptabler), which flushes and deletes the DOCKER* chains, then only rebuilds rules for its own networks. In the host netns that wipes the host daemon's rules.

Related: docker-library/docker#443 (comment from a maintainer recommending against dind with --network=host), getumbrel/umbrel-apps#5802 (same breakage via Portainer's dind).

Kept it as a short note next to the existing --privileged one; happy to reword or move it.

Comment thread docker/content.md Outdated

**Note:** `--privileged` is required for Docker-in-Docker to function properly, but it should be used with care as it provides full access to the host environment, as explained [in the relevant section of the Docker documentation](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).

**Note:** avoid combining `--privileged` with `--network=host` when the host itself runs Docker. The daemon inside the container manages iptables in whatever network namespace it runs in, and on startup it flushes and recreates Docker's chains (`DOCKER`, `DOCKER-FORWARD`, `DOCKER-CT`, `DOCKER-BRIDGE`, and `DOCKER` in the `nat` table). With `--network=host` those are the host daemon's chains, so containers on the host's bridge networks can lose outbound access and published ports until the host daemon is restarted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts:

  • two Note: blocks back-to-back reads kind of odd
  • adding --privileged to this note isn't necessary (this image can't be run without privileged, as noted above)
  • "when the host itself runs Docker" is practically a tautology here (why would someone run this image without Docker?)

Suggested rewording:

Suggested change
**Note:** avoid combining `--privileged` with `--network=host` when the host itself runs Docker. The daemon inside the container manages iptables in whatever network namespace it runs in, and on startup it flushes and recreates Docker's chains (`DOCKER`, `DOCKER-FORWARD`, `DOCKER-CT`, `DOCKER-BRIDGE`, and `DOCKER` in the `nat` table). With `--network=host` those are the host daemon's chains, so containers on the host's bridge networks can lose outbound access and published ports until the host daemon is restarted.
**Warning:** do not run `%%IMAGE%%:dind` with `--network=host`. The Docker daemon manages iptables rules in whatever network namespace it runs in, and on startup it removes Docker's `DOCKER*` chains and recreates only the rules for its own networks. With `--network=host`, that namespace is the host's, so the chains it removes are the host's own Docker daemon's: containers on the host's bridge networks can lose outbound access, and published ports can stop working, until the host's daemon recreates its rules.

@ladydd

ladydd commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Applied the suggested wording.

@tianon tianon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tianon
tianon merged commit 0684274 into docker-library:master Nov 25, 2026
6 checks passed
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.

2 participants