daemon/start.go
4180b875
 package daemon
 
 import (
c79b9bab
 	"fmt"
39ad38cc
 	"runtime"
c79b9bab
 
4180b875
 	"github.com/docker/docker/runconfig"
 )
 
767df67e
 func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error {
d25a6537
 	container, err := daemon.Get(name)
 	if err != nil {
c79b9bab
 		return err
4180b875
 	}
 
02246d2d
 	if container.IsPaused() {
c79b9bab
 		return fmt.Errorf("Cannot start a paused container, try unpause instead.")
02246d2d
 	}
 
e0339d4b
 	if container.IsRunning() {
c79b9bab
 		return fmt.Errorf("Container already started")
4180b875
 	}
 
b37832e3
 	if _, err = daemon.verifyContainerSettings(hostConfig, nil); err != nil {
1a35b16b
 		return err
 	}
 
39ad38cc
 	// Windows does not have the backwards compatibilty issue here.
 	if runtime.GOOS != "windows" {
 		// 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
 			}
 		}
 	} else {
 		if hostConfig != nil {
 			return fmt.Errorf("Supplying a hostconfig on start is not supported. It should be supplied on create")
4180b875
 		}
 	}
767df67e
 
4180b875
 	if err := container.Start(); err != nil {
c79b9bab
 		return fmt.Errorf("Cannot start container %s: %s", name, err)
4180b875
 	}
6ae05936
 
c79b9bab
 	return nil
4180b875
 }