mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
08d75bc450
commit d379f7645026001ce57fd6421c819f6c7df77964 Author: Matthew Mayer <matthewkmayer@gmail.com> Date: Mon Mar 23 22:13:06 2015 -0700 Removes unused imports. Signed-off-by: Matthew Mayer <matthewkmayer@gmail.com> commit 6e1f77c7f1566c8719087d88fbe06bade122691c Author: Matthew Mayer <matthewkmayer@gmail.com> Date: Mon Mar 23 20:41:16 2015 -0700 Removes bind dir creation in daemon start. Signed-off-by: Matthew Mayer <matthewkmayer@gmail.com> Signed-off-by: Matthew Mayer <matthewkmayer@gmail.com>
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package daemon
|
|
|
|
import (
|
|
"github.com/docker/docker/engine"
|
|
"github.com/docker/docker/runconfig"
|
|
)
|
|
|
|
func (daemon *Daemon) ContainerStart(job *engine.Job) engine.Status {
|
|
if len(job.Args) < 1 {
|
|
return job.Errorf("Usage: %s container_id", job.Name)
|
|
}
|
|
var (
|
|
name = job.Args[0]
|
|
)
|
|
|
|
container, err := daemon.Get(name)
|
|
if err != nil {
|
|
return job.Error(err)
|
|
}
|
|
|
|
if container.IsPaused() {
|
|
return job.Errorf("Cannot start a paused container, try unpause instead.")
|
|
}
|
|
|
|
if container.IsRunning() {
|
|
return job.Errorf("Container already started")
|
|
}
|
|
|
|
// If no environment was set, then no hostconfig was passed.
|
|
// This is kept for backward compatibility - hostconfig should be passed when
|
|
// creating a container, not during start.
|
|
if len(job.Environ()) > 0 {
|
|
hostConfig := runconfig.ContainerHostConfigFromJob(job)
|
|
if err := daemon.setHostConfig(container, hostConfig); err != nil {
|
|
return job.Error(err)
|
|
}
|
|
}
|
|
if err := container.Start(); err != nil {
|
|
container.LogEvent("die")
|
|
return job.Errorf("Cannot start container %s: %s", name, err)
|
|
}
|
|
|
|
return engine.StatusOK
|
|
}
|
|
|
|
func (daemon *Daemon) setHostConfig(container *Container, hostConfig *runconfig.HostConfig) error {
|
|
container.Lock()
|
|
defer container.Unlock()
|
|
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Register any links from the host config before starting the container
|
|
if err := daemon.RegisterLinks(container, hostConfig); err != nil {
|
|
return err
|
|
}
|
|
|
|
container.hostConfig = hostConfig
|
|
container.toDisk()
|
|
|
|
return nil
|
|
}
|