Repository navigation
docker: note that dind with --network=host clobbers the host's iptables chains - #2722
Merged
Merged
Conversation
tianon
reviewed
Nov 24, 2026
|
|
||
| **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. |
Member
There was a problem hiding this comment.
A few thoughts:
- two
Note:blocks back-to-back reads kind of odd - adding
--privilegedto 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. |
Contributor
Author
|
Applied the suggested wording. |
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.
Ran into this with a CI runner image based on
dindthat 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 theDOCKER*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
--privilegedone; happy to reword or move it.