fix(docker): give rootlesskit a port driver, so -p means something - #13
Merged
Conversation
`docker run -p` published nothing. `docker port` reported 0.0.0.0:<port> and no connection succeeded, not even from inside this container on 127.0.0.1 — because RootlessKit defaults --port-driver to `none`, which maps the port inside its own namespace and forwards it nowhere. The flag normally arrives with dockerd-rootless.sh, which passes it explicitly. This image cannot use that script — docker-ce-rootless-extras is unavailable, as core/Dockerfile.frag section 1 records — so the invocation was reimplemented by hand and the flag was the piece that got lost. Everything else was right: slirp4netns is installed, networking works, containers run. The comment above the invocation asserted the opposite, naming Testcontainers as a consumer that reaches a published port this way. Nothing had ever exercised it. No isolation is traded for this. The host socket is still not mounted, no privilege is added, the user namespace is unchanged. It turns on forwarding for ports of containers this daemon already creates — exactly the capability the file already claimed to have. --disable-host-loopback is orthogonal and stays: it blocks a nested container dialling into its parent, not the parent reaching a published port. Unverified: proving it needs an image rebuild and a container restart. The reproduction is `docker run -d -p 15432:5432 postgres:18-alpine` followed by a TCP connect to 127.0.0.1:15432 from this container. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TjvhhztqTYoQhJcJTgXdRb
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.
docker run -ppublished nothing in this image.docker portreported0.0.0.0:<port>and no connection succeeded — not even from inside the containeritself, on
127.0.0.1.Cause
RootlessKit defaults
--port-drivertonone, which maps a published port insideRootlessKit's own namespace and forwards it nowhere.
svc-dockerd-rootless/runneverpassed the flag.
The flag normally arrives with
dockerd-rootless.sh, which sets it explicitly. Thisimage cannot use that script —
docker-ce-rootless-extrasis unavailable, ascore/Dockerfile.fragsection 1 already records — so the invocation was reimplementedby hand, and this is the piece that got lost. Everything else was right:
slirp4netnsis installed, networking works, containers build and run,docker execworks. Only forwarding was missing, which is why it went unnoticed.
The comment was asserting the opposite
The block above the invocation claimed publishing worked, and named Testcontainers as
a consumer that reaches a published port this way. Nothing had ever exercised it. It is
rewritten to say what actually happens and why the flag has to be there.
Isolation
Nothing is traded. The host Docker socket is still not mounted, no privilege is
added, the user namespace is unchanged. This turns on forwarding for ports of
containers this daemon already creates — the capability the file already claimed to
have.
--disable-host-loopbackis orthogonal and stays. It blocks a nested container diallingback into its parent; it has nothing to do with the parent reaching a published port.
builtinis whatdockerd-rootless.shdefaults to and is the faster of the two;slirp4netnsis the fallback if a workload ever needs the source IP preserved.Not verified
Proving it needs an image rebuild and a container restart, which ends the session that
found it. The reproduction is in the commit and is two commands:
Today that prints
refusedwhiledocker portshows the mapping.How it was found
A consumer project reached for Testcontainers and could not connect. Docker itself was
fine — a container ran and answered over
docker exec— which is what pointed atforwarding rather than at the daemon.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TjvhhztqTYoQhJcJTgXdRb