mirror of
https://github.com/opencontainers/runc.git
synced 2026-04-22 23:17:17 +08:00
libct: document initConfig and friends
This is one of the dark corners of runc / libcontainer, so let's shed some light on it. initConfig is a structure which is filled in [mostly] by newInitConfig, and one of its hidden aspects is it contains a process config which is the result of merge between the container and the process configs. Let's document how all this happens, where the fields are coming from, which one has a preference, and how it all works. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -689,6 +689,9 @@ func (c *Container) newSetnsProcess(p *Process, cmd *exec.Cmd, comm *processComm
|
||||
}
|
||||
|
||||
func (c *Container) newInitConfig(process *Process) *initConfig {
|
||||
// Set initial properties. For those properties that exist
|
||||
// both in the container config and the process, use the ones
|
||||
// from the container config first, and override them later.
|
||||
cfg := &initConfig{
|
||||
Config: c.config,
|
||||
Args: process.Args,
|
||||
@@ -710,6 +713,9 @@ func (c *Container) newInitConfig(process *Process) *initConfig {
|
||||
ConsoleWidth: process.ConsoleWidth,
|
||||
ConsoleHeight: process.ConsoleHeight,
|
||||
}
|
||||
|
||||
// Overwrite config properties with ones from process.
|
||||
|
||||
if process.NoNewPrivileges != nil {
|
||||
cfg.NoNewPrivileges = *process.NoNewPrivileges
|
||||
}
|
||||
@@ -722,6 +728,9 @@ func (c *Container) newInitConfig(process *Process) *initConfig {
|
||||
if len(process.Rlimits) > 0 {
|
||||
cfg.Rlimits = process.Rlimits
|
||||
}
|
||||
|
||||
// Set misc properties.
|
||||
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
cfg.Cgroup2Path = c.cgroupManager.Path("")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user