github.com/sams1990/dockerrepo@v17.12.1-ce-rc2+incompatible/daemon/start_unix.go (about) 1 // +build !windows 2 3 package daemon 4 5 import ( 6 "fmt" 7 "os/exec" 8 "path/filepath" 9 10 "github.com/containerd/containerd/linux/runctypes" 11 "github.com/docker/docker/container" 12 "github.com/pkg/errors" 13 ) 14 15 func (daemon *Daemon) getRuntimeScript(container *container.Container) (string, error) { 16 name := container.HostConfig.Runtime 17 rt := daemon.configStore.GetRuntime(name) 18 if rt == nil { 19 return "", validationError{errors.Errorf("no such runtime '%s'", name)} 20 } 21 22 if len(rt.Args) > 0 { 23 // First check that the target exist, as using it in a script won't 24 // give us the right error 25 if _, err := exec.LookPath(rt.Path); err != nil { 26 return "", translateContainerdStartErr(container.Path, container.SetExitCode, err) 27 } 28 return filepath.Join(daemon.configStore.Root, "runtimes", name), nil 29 } 30 return rt.Path, nil 31 } 32 33 // getLibcontainerdCreateOptions callers must hold a lock on the container 34 func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) (interface{}, error) { 35 // Ensure a runtime has been assigned to this container 36 if container.HostConfig.Runtime == "" { 37 container.HostConfig.Runtime = daemon.configStore.GetDefaultRuntimeName() 38 container.CheckpointTo(daemon.containersReplica) 39 } 40 41 path, err := daemon.getRuntimeScript(container) 42 if err != nil { 43 return nil, err 44 } 45 opts := &runctypes.RuncOptions{ 46 Runtime: path, 47 RuntimeRoot: filepath.Join(daemon.configStore.ExecRoot, 48 fmt.Sprintf("runtime-%s", container.HostConfig.Runtime)), 49 } 50 51 if UsingSystemd(daemon.configStore) { 52 opts.SystemdCgroup = true 53 } 54 55 return opts, nil 56 }