Join mount namespace of another container
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- go
- Domain
- infrastructure
Research direction
Start with libcontainer/rootfs_linux.go, especially prepareRoot(), and compare the reported namespace configurations with the runtime-spec root requirement. Reproduce the mount-namespace attempts and their errors; done means establishing whether runc can support this configuration and defining the required behavior or specification change.
Written by the indexing model from the issue text.
Description
Hi,
I'm trying to use runc to launch a container (my-container2) which joins the mount namespace of another running container (my-container1). Below is a (pretty long) description of the different configurations I've tried, and the errors I've hit.
my-container1is a bundle withconfig.jsongenerated withrunc specand a busybox rootfs.my-container2is another bundle with a minimal config, pointing to the mount namespace and rootfs ofmy-container1, as in the following config:
{
"ociVersion": "1.0.0",
"process": {
"terminal": false,
"user": {
"uid": 0, "gid": 0
},
"args": [
"sleep", "1h"
],
"cwd": "/"
},
"root": {
"path": "/home/zvic/Temp/oci/my-container1/rootfs"
},
"linux": {
"namespaces": [
{
"type": "pid"
},
{
"type": "network"
},
{
"type": "ipc"
},
{
"type": "uts"
},
{
"type": "mount",
"path": "/proc/9830/ns/mnt"
}
]
}
}
While my-container1 is running, I try to launch my-container2:
zvic@zvic-vbox:~/Temp/oci$ sudo ./runc run -d --bundle=my-container2 my-container2
container_linux.go:265: starting container process caused "process_linux.go:348: container init caused \"rootfs_linux.go:45: preparing rootfs caused \\\"open /proc/self/mountinfo: no such file or directory\\\"\""
I then modify my-container2 to also join the PID namespace of my-container1:
{
"type": "pid",
"path": "/proc/9830/ns/pid"
}
And try to launch again:
zvic@zvic-vbox:~/Temp/oci$ sudo ./runc run -d --bundle=my-container2 my-container2
container_linux.go:265: starting container process caused "process_linux.go:348: container init caused \"rootfs_linux.go:45: preparing rootfs caused \\\"no such file or directory\\\"\""
Adding some debug printing to runc, it appears that the "no such file or directory" error originates from prepareRoot(), while trying to bind-mount the rootfs:
func prepareRoot(config *configs.Config) error {
...
return unix.Mount(config.Rootfs, config.Rootfs, "bind", unix.MS_BIND|unix.MS_REC, "")
}
I've also tried modifying root.path to "../my-container1/rootfs" (relative path) or to "" (empty), but got the exact same error.
I then tried setting root.path to "/", and the error became:
zvic@zvic-vbox:~/Temp/oci$ sudo ./runc run -d --bundle=my-container2 my-container2
container_linux.go:265: starting container process caused "process_linux.go:348: container init caused \"rootfs_linux.go:105: jailing process inside rootfs caused \\\"pivot_root device or resource busy\\\"\""
Adding the --no-pivot flag caused this:
zvic@zvic-vbox:~/Temp/oci$ sudo ./runc run -d --no-pivot --bundle=my-container2 my-container2
container_linux.go:265: starting container process caused "process_linux.go:348: container init caused \"rootfs_linux.go:105: jailing process inside rootfs caused \\\"too many levels of symbolic links\\\"\""
On a last and desperate attempt, I simply omitted root from the config.json of my-container2, and no-surprisingly, got the following error:
zvic@zvic-vbox:~/Temp/oci$ sudo ./runc run -d --bundle=my-container2 my-container2
Root must be specified
This is indeed seems to be forbidden by the runtime-spec, but actually is the configuration that most accurately describes the semantics I'm after (that is, joining a mount namespace in which the rootfs is already set up).
- Dominant language
- Go
- Stars
- 13.5k
- Forks
- 2.3k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 30
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opencontainers/runc
-
`root.readonly` is silently ignored (rootfs left writable) when the container has no mount namespace Openllm-generated
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opencontainers/runc#5371 ·
-
llm-generated
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
opencontainers/runc#5370 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
opencontainers/runc#2214 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
opencontainers/runc#1679 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
opencontainers/runc#5474 ·
All issues in opencontainers/runc
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100