Repository navigation
Description
We currently run the shim both outside the container (to reconfigure the runc bundle) and inside exec containers, which makes it straightforward to redirect stdout/stderr, serve nested sessions, etc. It's the pid 1 and spawns the actual user process as a subchild.
However, this can cause problems for programs that insist on being pid 1 such as systemd.
We can instead run the shim completely outside the container. This will require at least:
- Still handling stdout/stderr file redirects correctly, including when they are to submounts.
- Most promising path here may be to use
/proc/<pid>/rootto get access to the full filesystem the container sees.
- Most promising path here may be to use
- Serving nested sessions
- This will likely require nsenter'ing into the network namespace of the container
- It also requires that the session reads and writes files from under
/proc/<pid>/rootfor all relevant APIs, including file sync. File sync specifically can likely be addressed via some tweaks to our callback here.
There might be more than that, but that's what immediately comes to mind.
One annoying part of this is that we currently use runc run, which combines create/start/stop into a single operation. But to get the container pid and setup file access in a non-racey way we'll probably need to split out into separate create/start/stop operations.
Not a requirement, but we could also consider moving the shim to a different approach as part of this if it makes any of this easier. Two ideas:
- Switch to a containerd backend and convert our shim to be an actual containerd shim
- Implement the shim functionality as a custom buildkit executor, which is possible now that we are using buildkit as a library with in our own custom engine binary.
2 in particular is intriguing in that it may open more avenues such as adding custom session attachables, but it has the major potential downside of us needing to copy a lot of code from buildkit, which makes maintaining it harder in the long run.
We can also consider upstreaming at least the stdout/stderr handling, but I think the nested session might be too dagger specific to upstream unless we can think of a generic way of modeling it.
Activity