mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
oci: include the domainname in "kernel.domainname"
The OCI doesn't have a specific field for an NIS domainname[1] (mainly because FreeBSD and Solaris appear to have a similar concept but it is configured entirely differently). However, on Linux, the NIS domainname can be configured through both the setdomainname(2) syscall but also through the "kernel.domainname" sysctl. Since the OCI has a way of injecting sysctls this means we don't need to have any OCI changes to support NIS domainnames (and we can always switch if the OCI picks up such support in the future). It should be noted that because we have to generate this each spec creation we also have to make sure that it's not clobbered by the HostConfig. I'm pretty sure making this change generic (so that HostConfig will not clobber any pre-set sysctls) will not cause other issues to crop up. [1]: https://github.com/opencontainers/runtime-spec/issues/592 Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
852542b397
commit
7417f50575
1 changed files with 14 additions and 2 deletions
|
@ -678,7 +678,15 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
|
|||
s.Process.Cwd = cwd
|
||||
s.Process.Env = c.CreateDaemonEnvironment(c.Config.Tty, linkedEnv)
|
||||
s.Process.Terminal = c.Config.Tty
|
||||
s.Hostname = c.FullHostname()
|
||||
|
||||
s.Hostname = c.Config.Hostname
|
||||
// There isn't a field in the OCI for the NIS domainname, but luckily there
|
||||
// is a sysctl which has an identical effect to setdomainname(2) so there's
|
||||
// no explicit need for runtime support.
|
||||
s.Linux.Sysctl = make(map[string]string)
|
||||
if c.Config.Domainname != "" {
|
||||
s.Linux.Sysctl["kernel.domainname"] = c.Config.Domainname
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -714,7 +722,11 @@ func (daemon *Daemon) createSpec(c *container.Container) (retSpec *specs.Spec, e
|
|||
if err := setResources(&s, c.HostConfig.Resources); err != nil {
|
||||
return nil, fmt.Errorf("linux runtime spec resources: %v", err)
|
||||
}
|
||||
s.Linux.Sysctl = c.HostConfig.Sysctls
|
||||
// We merge the sysctls injected above with the HostConfig (latter takes
|
||||
// precedence for backwards-compatibility reasons).
|
||||
for k, v := range c.HostConfig.Sysctls {
|
||||
s.Linux.Sysctl[k] = v
|
||||
}
|
||||
|
||||
p := s.Linux.CgroupsPath
|
||||
if useSystemd {
|
||||
|
|
Loading…
Reference in a new issue