Repository navigation
Find the host data path without a self-inspection - #340
Merged
Merged
Conversation
A host-networked container shares the host's UTS namespace, so its hostname is the machine name and the daemon has no container to inspect. Self-detection then concluded 'not a container' and used the data directory as-is, which would have asked the daemon to bind /app/data on the host: an empty root-owned directory instead of the world. Resolve now falls back to the kernel mount table, where the source path of a bind mount is recorded, before giving up. The daemon's view still wins when it has one, and a container whose mounts do not cover the data directory is still refused.
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.
Found while updating the local dev instance: it runs with
network_mode: host, and the new self-detection reportedServer data directory /app/data is used as-is by the Docker host (no translation).Why
A host-networked container shares the host's UTS namespace, so
os.Hostname()returns the machine name (DESKTOP-81EKL5T), not the container ID.ContainerInspecttherefore returns 404, which the client correctly reports as "not a container", and the resolver fell back to the identity mapping.That is the worst kind of fallback: the panel would ask the daemon to bind
/app/data/servers/xon the host, where no such directory exists. Docker would create an empty root-owned directory and mount it into the server container instead of the world.Fix
Resolvenow has a second source before it gives up: the kernel mount table. For a bind mount the kernel records the source path in therootfield, so/app/datainside the container maps to/opt/carbon-panel/dataon the host with no daemon call at all.Order of authority:
CARBONPANEL_HOST_DATA_PATH.A container whose mounts are visible but do not cover the data directory is still refused with
ErrNotMounted, whether the answer came from the daemon or the kernel.This also covers a Docker socket proxy that forbids
GET /containers/**: the mapping is still correct without container read access.Verification
go build ./...,go vet ./...,go test ./internal/hostmount ./internal/docker ./cmd/..., knowledge-lint 10/10.maps to /opt/carbon-panel/data on the Docker host (container mount table).