Expand description
mount — Mount / volume attach primitives.
This slice’s concrete target: resolving the real mount-namespace
handle of an already-running process on the host, by pid — filling
principal::ContainerRef::mount_ns, which is unconditionally None
until something actually resolves it. lifecycle::Lifecycle::container_ref
is the caller that wires this in for a real dockerd container.
Scope boundary (hard constraint, same as every substrate-kit
module): this resolves what a container’s mount namespace is,
never who should be allowed to bind-mount into it or why — that’s
an authorization/policy question for identity-kit, not this
crate. See principal.rs’s module doc for the full hard-constraint
statement.
Real, environment-dependent permission boundary — not a bug:
reading another user’s /proc/<pid>/ns/* requires the same real/
effective/saved uid as the target process, or CAP_SYS_PTRACE. A
dockerd container’s process typically runs as root on the host; a
non-root caller resolving its mount namespace gets a real
permission-denied SubstrateError::Io here, and that is the correct
answer for this function to give, not a defect. lifecycle’s live
tests document exactly what they can and can’t prove on a non-root
test run — see that module’s mod live doc.
§Volume attach: VolumeMount
The second half of this module is the declarative volume seam a
crate::lifecycle::ContainerSpec carries: VolumeMount describes a
named Docker volume to attach to a container, optionally backed by a
volume-plugin driver (for example a content-addressed storage
driver). dockerd creates the volume on first reference
(docker run --mount type=volume,... semantics).
Deliberately no host bind mounts. An arbitrary host path is a different trust decision from a named volume (it can expose any part of the host filesystem to a container), so a host path must never be derived from untrusted input. Bind mounts, tmpfs and anything that names a host path are therefore not representable here; they would arrive as a separate, explicitly-reviewed type, not as a string convention on this one.
Enforced, not just documented. VolumeMount::validate rejects the
local driver (case-insensitive) and the driver option keys device,
o and type (case-insensitive), because the local driver turns
type=none,o=bind,device=/host/path into a host bind mount of any path.
A third-party plugin driver is trusted to be a plugin; this crate cannot
inspect what a plugin does with its options.
Driver options (with_driver) are stored in dockerd’s volume metadata
and are visible to anyone who can docker volume inspect: never put a
credential in them.
Full mount/volume attach primitives beyond that (bind-mounting into a running container’s namespace, rather than reading its handle back) remain deferred; no epic exists for them.
Structs§
- Volume
Driver - A volume-plugin driver selection for a
VolumeMount. - Volume
Mount - A named Docker volume to attach to a container at
target.
Functions§
- resolve_
mount_ namespace - Resolve the mount-namespace handle for a running process on the host,
by pid — the
/proc/<pid>/ns/mntsymlink target (mnt:[<inode>]), exactly the opaque handle formatContainerRef::mount_ns’s own doc example (/proc/4242/ns/mnt) points at.