Skip to content

fix(container): inherit only user mounts with volumes-from - #5250

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
git-jxj:fix/volumes-from-user-mounts-2667
Oct 13, 2026
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
git-jxj:fix/volumes-from-user-mounts-2667

Conversation

@git-jxj

@git-jxj git-jxj commented Oct 8, 2026

Copy link
Copy Markdown

--volumes-from currently copies the source container's complete OCI mount list, so its default /dev/shm mount replaces a bind mount configured on the target container. Restrict inherited mounts to destinations recorded in the source container's user mount metadata, preserving their original OCI options. Keep mount and anonymous-volume metadata scoped to each source container.

Fixes #2667.

Validation: the new runtime regression fails before the change and passes afterward; the existing TestRunVolumesFrom, make test, builds, and changed-code Go lint pass. YAML, module, confinement, license, and commit checks also pass. Full lint reports the same existing Go formatting and shellcheck failures on the clean upstream baseline.

AI assistance: Codex assisted with the implementation, regression test, and PR description.

The source container's complete OCI mount list includes default mounts,
which can replace the target container's own /dev/shm configuration.
Select only destinations recorded in the source container's mount labels,
while preserving their OCI mount options and volume metadata.

Add a runtime regression that combines an inherited read-only bind mount
with a separate /dev/shm bind mount on the target container.

Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io>
Assisted-by: Codex

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation preserves user mount options, avoids system-mount inheritance, and includes an effective regression test.

0 open findings

What changed in this PR

Restricts --volumes-from to user-defined mounts, preventing source system mounts from overriding target mounts.

Changes:

  • Filters inherited OCI mounts using source mount metadata.
  • Scopes mount and anonymous-volume metadata per source container.
  • Adds a /dev/shm regression test.
File Description
pkg/​cmd/​container/​run_mount.go Filters and scopes inherited mounts.
cmd/​nerdctl/​container/​container_run_mount_linux_test.go Tests preservation of the target /dev/shm bind mount.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AkihiroSuda AkihiroSuda modified the milestones: v2.5.0 (tentative), v2.4.2 Oct 9, 2026
@git-jxj

git-jxj commented Oct 10, 2026

Copy link
Copy Markdown
Author

The remaining failed gomodjail job reports only TestRunRmTime: run --rm took 12.55s against its 3s deadline. That test does not pass --volumes-from, so it does not enter the inheritance block changed here; the same timing test also failed on the unrelated compose PR #5251. The other 33 checks passed. I tried rerunning this failed job, but GitHub rejected the request with a permission error. Could a maintainer rerun the job?

@AkihiroSuda AkihiroSuda 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

@AkihiroSuda
AkihiroSuda merged commit 805511a into containerd:main Oct 13, 2026
52 of 56 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.

using volumes-from mount additional folders

3 participants