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