github.com/ehazlett/containerd@v0.2.5/supervisor/create.go (about) 1 package supervisor 2 3 import ( 4 "path/filepath" 5 "time" 6 7 "github.com/docker/containerd/runtime" 8 ) 9 10 // StartTask holds needed parameters to create a new container 11 type StartTask struct { 12 baseTask 13 ID string 14 BundlePath string 15 Stdout string 16 Stderr string 17 Stdin string 18 StartResponse chan StartResponse 19 Labels []string 20 NoPivotRoot bool 21 Checkpoint *runtime.Checkpoint 22 CheckpointDir string 23 Runtime string 24 RuntimeArgs []string 25 } 26 27 func (s *Supervisor) start(t *StartTask) error { 28 start := time.Now() 29 rt := s.runtime 30 rtArgs := s.runtimeArgs 31 if t.Runtime != "" { 32 rt = t.Runtime 33 rtArgs = t.RuntimeArgs 34 } 35 container, err := runtime.New(runtime.ContainerOpts{ 36 Root: s.stateDir, 37 ID: t.ID, 38 Bundle: t.BundlePath, 39 Runtime: rt, 40 RuntimeArgs: rtArgs, 41 Shim: s.shim, 42 Labels: t.Labels, 43 NoPivotRoot: t.NoPivotRoot, 44 Timeout: s.timeout, 45 }) 46 if err != nil { 47 return err 48 } 49 s.containers[t.ID] = &containerInfo{ 50 container: container, 51 } 52 ContainersCounter.Inc(1) 53 task := &startTask{ 54 Err: t.ErrorCh(), 55 Container: container, 56 StartResponse: t.StartResponse, 57 Stdin: t.Stdin, 58 Stdout: t.Stdout, 59 Stderr: t.Stderr, 60 } 61 if t.Checkpoint != nil { 62 task.CheckpointPath = filepath.Join(t.CheckpointDir, t.Checkpoint.Name) 63 } 64 65 s.startTasks <- task 66 ContainerCreateTimer.UpdateSince(start) 67 return errDeferredResponse 68 }