github.com/sevki/docker@v1.7.1/daemon/start.go (about) 1 package daemon 2 3 import ( 4 "fmt" 5 6 "github.com/docker/docker/runconfig" 7 ) 8 9 func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error { 10 container, err := daemon.Get(name) 11 if err != nil { 12 return err 13 } 14 15 if container.IsPaused() { 16 return fmt.Errorf("Cannot start a paused container, try unpause instead.") 17 } 18 19 if container.IsRunning() { 20 return fmt.Errorf("Container already started") 21 } 22 23 if _, err = daemon.verifyHostConfig(hostConfig); err != nil { 24 return err 25 } 26 27 // This is kept for backward compatibility - hostconfig should be passed when 28 // creating a container, not during start. 29 if hostConfig != nil { 30 if err := daemon.setHostConfig(container, hostConfig); err != nil { 31 return err 32 } 33 } 34 35 if err := container.Start(); err != nil { 36 container.LogEvent("die") 37 return fmt.Errorf("Cannot start container %s: %s", name, err) 38 } 39 40 return nil 41 }