github.com/psychoss/docker@v1.9.0/daemon/start.go (about) 1 package daemon 2 3 import ( 4 "runtime" 5 6 derr "github.com/docker/docker/errors" 7 "github.com/docker/docker/runconfig" 8 "github.com/docker/docker/utils" 9 ) 10 11 // ContainerStart starts a container. 12 func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error { 13 container, err := daemon.Get(name) 14 if err != nil { 15 return err 16 } 17 18 if container.isPaused() { 19 return derr.ErrorCodeStartPaused 20 } 21 22 if container.IsRunning() { 23 return derr.ErrorCodeAlreadyStarted 24 } 25 26 // Windows does not have the backwards compatibility issue here. 27 if runtime.GOOS != "windows" { 28 // This is kept for backward compatibility - hostconfig should be passed when 29 // creating a container, not during start. 30 if hostConfig != nil { 31 if err := daemon.setHostConfig(container, hostConfig); err != nil { 32 return err 33 } 34 } 35 } else { 36 if hostConfig != nil { 37 return derr.ErrorCodeHostConfigStart 38 } 39 } 40 41 // check if hostConfig is in line with the current system settings. 42 // It may happen cgroups are umounted or the like. 43 if _, err = daemon.verifyContainerSettings(container.hostConfig, nil); err != nil { 44 return err 45 } 46 47 if err := container.Start(); err != nil { 48 return derr.ErrorCodeCantStart.WithArgs(name, utils.GetErrorMessage(err)) 49 } 50 51 return nil 52 }