mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
LCOW:Reworking spec builder
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
20833b06a0
commit
d4ceb61f2b
3 changed files with 30 additions and 13 deletions
|
@ -681,13 +681,7 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
|
|||
s.Process.Terminal = c.Config.Tty
|
||||
|
||||
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
|
||||
}
|
||||
setLinuxDomainname(c, s)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
16
daemon/oci_utils.go
Normal file
16
daemon/oci_utils.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package daemon // import "github.com/docker/docker/daemon"
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
func setLinuxDomainname(c *container.Container, s *specs.Spec) {
|
||||
// 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
|
||||
}
|
||||
}
|
|
@ -43,9 +43,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
|||
// this is done in VMCompute. Further, we couldn't do it for Hyper-V
|
||||
// containers anyway.
|
||||
|
||||
// In base spec
|
||||
s.Hostname = c.FullHostname()
|
||||
|
||||
if err := daemon.setupSecretDir(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -128,8 +125,9 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
|||
// In s.Process
|
||||
s.Process.Cwd = c.Config.WorkingDir
|
||||
s.Process.Env = c.CreateDaemonEnvironment(c.Config.Tty, linkedEnv)
|
||||
s.Process.Terminal = c.Config.Tty
|
||||
|
||||
if c.Config.Tty {
|
||||
s.Process.Terminal = c.Config.Tty
|
||||
s.Process.ConsoleSize = &specs.Box{
|
||||
Height: c.HostConfig.ConsoleSize[0],
|
||||
Width: c.HostConfig.ConsoleSize[1],
|
||||
|
@ -228,6 +226,8 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
|||
// Sets the Windows-specific fields of the OCI spec
|
||||
func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error {
|
||||
|
||||
s.Hostname = c.FullHostname()
|
||||
|
||||
if len(s.Process.Cwd) == 0 {
|
||||
// We default to C:\ to workaround the oddity of the case that the
|
||||
// default directory for cmd running as LocalSystem (or
|
||||
|
@ -360,13 +360,20 @@ func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.S
|
|||
// TODO: @jhowardmsft LCOW Support. We need to do a lot more pulling in what can
|
||||
// be pulled in from oci_linux.go.
|
||||
func (daemon *Daemon) createSpecLinuxFields(c *container.Container, s *specs.Spec) error {
|
||||
s.Root = &specs.Root{
|
||||
Path: "rootfs",
|
||||
Readonly: c.HostConfig.ReadonlyRootfs,
|
||||
}
|
||||
|
||||
s.Hostname = c.Config.Hostname
|
||||
setLinuxDomainname(c, s)
|
||||
|
||||
if len(s.Process.Cwd) == 0 {
|
||||
s.Process.Cwd = `/`
|
||||
}
|
||||
s.Process.Args = append([]string{c.Path}, c.Args...)
|
||||
s.Root.Path = "rootfs"
|
||||
s.Root.Readonly = c.HostConfig.ReadonlyRootfs
|
||||
|
||||
// Note these are against the UVM.
|
||||
setResourcesInSpec(c, s, true) // LCOW is Hyper-V only
|
||||
|
||||
capabilities, err := caps.TweakCapabilities(oci.DefaultCapabilities(), c.HostConfig.CapAdd, c.HostConfig.CapDrop, c.HostConfig.Capabilities, c.HostConfig.Privileged)
|
||||
|
|
Loading…
Add table
Reference in a new issue