mirror of https://github.com/docker/docs.git
Add clean if start fail
This commit is contained in:
parent
2b92aa71f9
commit
664acd2971
484
container.go
484
container.go
|
@ -567,262 +567,270 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
||||||
container.State.Lock()
|
container.State.Lock()
|
||||||
defer container.State.Unlock()
|
defer container.State.Unlock()
|
||||||
|
|
||||||
if hostConfig == nil { // in docker start of docker restart we want to reuse previous HostConfigFile
|
startFct := func(hostConfig *HostConfig) error {
|
||||||
hostConfig, _ = container.ReadHostConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
if container.State.Running {
|
if hostConfig == nil { // in docker start of docker restart we want to reuse previous HostConfigFile
|
||||||
return fmt.Errorf("The container %s is already running.", container.ID)
|
hostConfig, _ = container.ReadHostConfig()
|
||||||
}
|
}
|
||||||
if err := container.EnsureMounted(); err != nil {
|
|
||||||
return err
|
if container.State.Running {
|
||||||
}
|
return fmt.Errorf("The container %s is already running.", container.ID)
|
||||||
if container.runtime.networkManager.disabled {
|
}
|
||||||
container.Config.NetworkDisabled = true
|
if err := container.EnsureMounted(); err != nil {
|
||||||
} else {
|
|
||||||
if err := container.allocateNetwork(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
if container.runtime.networkManager.disabled {
|
||||||
|
container.Config.NetworkDisabled = true
|
||||||
// Make sure the config is compatible with the current kernel
|
|
||||||
if container.Config.Memory > 0 && !container.runtime.capabilities.MemoryLimit {
|
|
||||||
log.Printf("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
|
||||||
container.Config.Memory = 0
|
|
||||||
}
|
|
||||||
if container.Config.Memory > 0 && !container.runtime.capabilities.SwapLimit {
|
|
||||||
log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
|
||||||
container.Config.MemorySwap = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if container.runtime.capabilities.IPv4ForwardingDisabled {
|
|
||||||
log.Printf("WARNING: IPv4 forwarding is disabled. Networking will not work")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the requested bind mounts
|
|
||||||
binds := make(map[string]BindMap)
|
|
||||||
// Define illegal container destinations
|
|
||||||
illegalDsts := []string{"/", "."}
|
|
||||||
|
|
||||||
for _, bind := range hostConfig.Binds {
|
|
||||||
// FIXME: factorize bind parsing in parseBind
|
|
||||||
var src, dst, mode string
|
|
||||||
arr := strings.Split(bind, ":")
|
|
||||||
if len(arr) == 2 {
|
|
||||||
src = arr[0]
|
|
||||||
dst = arr[1]
|
|
||||||
mode = "rw"
|
|
||||||
} else if len(arr) == 3 {
|
|
||||||
src = arr[0]
|
|
||||||
dst = arr[1]
|
|
||||||
mode = arr[2]
|
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Invalid bind specification: %s", bind)
|
if err := container.allocateNetwork(); err != nil {
|
||||||
}
|
return err
|
||||||
|
|
||||||
// Bail if trying to mount to an illegal destination
|
|
||||||
for _, illegal := range illegalDsts {
|
|
||||||
if dst == illegal {
|
|
||||||
return fmt.Errorf("Illegal bind destination: %s", dst)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bindMap := BindMap{
|
// Make sure the config is compatible with the current kernel
|
||||||
SrcPath: src,
|
if container.Config.Memory > 0 && !container.runtime.capabilities.MemoryLimit {
|
||||||
DstPath: dst,
|
log.Printf("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
||||||
Mode: mode,
|
container.Config.Memory = 0
|
||||||
|
}
|
||||||
|
if container.Config.Memory > 0 && !container.runtime.capabilities.SwapLimit {
|
||||||
|
log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
||||||
|
container.Config.MemorySwap = -1
|
||||||
}
|
}
|
||||||
binds[path.Clean(dst)] = bindMap
|
|
||||||
}
|
|
||||||
|
|
||||||
if container.Volumes == nil || len(container.Volumes) == 0 {
|
if container.runtime.capabilities.IPv4ForwardingDisabled {
|
||||||
container.Volumes = make(map[string]string)
|
log.Printf("WARNING: IPv4 forwarding is disabled. Networking will not work")
|
||||||
container.VolumesRW = make(map[string]bool)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Apply volumes from another container if requested
|
// Create the requested bind mounts
|
||||||
if container.Config.VolumesFrom != "" {
|
binds := make(map[string]BindMap)
|
||||||
volumes := strings.Split(container.Config.VolumesFrom, ",")
|
// Define illegal container destinations
|
||||||
for _, v := range volumes {
|
illegalDsts := []string{"/", "."}
|
||||||
c := container.runtime.Get(v)
|
|
||||||
if c == nil {
|
for _, bind := range hostConfig.Binds {
|
||||||
return fmt.Errorf("Container %s not found. Impossible to mount its volumes", container.ID)
|
// FIXME: factorize bind parsing in parseBind
|
||||||
|
var src, dst, mode string
|
||||||
|
arr := strings.Split(bind, ":")
|
||||||
|
if len(arr) == 2 {
|
||||||
|
src = arr[0]
|
||||||
|
dst = arr[1]
|
||||||
|
mode = "rw"
|
||||||
|
} else if len(arr) == 3 {
|
||||||
|
src = arr[0]
|
||||||
|
dst = arr[1]
|
||||||
|
mode = arr[2]
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Invalid bind specification: %s", bind)
|
||||||
}
|
}
|
||||||
for volPath, id := range c.Volumes {
|
|
||||||
if _, exists := container.Volumes[volPath]; exists {
|
// Bail if trying to mount to an illegal destination
|
||||||
continue
|
for _, illegal := range illegalDsts {
|
||||||
}
|
if dst == illegal {
|
||||||
if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil {
|
return fmt.Errorf("Illegal bind destination: %s", dst)
|
||||||
return err
|
|
||||||
}
|
|
||||||
container.Volumes[volPath] = id
|
|
||||||
if isRW, exists := c.VolumesRW[volPath]; exists {
|
|
||||||
container.VolumesRW[volPath] = isRW
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
bindMap := BindMap{
|
||||||
}
|
SrcPath: src,
|
||||||
|
DstPath: dst,
|
||||||
// Create the requested volumes if they don't exist
|
Mode: mode,
|
||||||
for volPath := range container.Config.Volumes {
|
|
||||||
volPath = path.Clean(volPath)
|
|
||||||
// Skip existing volumes
|
|
||||||
if _, exists := container.Volumes[volPath]; exists {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var srcPath string
|
|
||||||
var isBindMount bool
|
|
||||||
srcRW := false
|
|
||||||
// If an external bind is defined for this volume, use that as a source
|
|
||||||
if bindMap, exists := binds[volPath]; exists {
|
|
||||||
isBindMount = true
|
|
||||||
srcPath = bindMap.SrcPath
|
|
||||||
if strings.ToLower(bindMap.Mode) == "rw" {
|
|
||||||
srcRW = true
|
|
||||||
}
|
}
|
||||||
// Otherwise create an directory in $ROOT/volumes/ and use that
|
binds[path.Clean(dst)] = bindMap
|
||||||
} else {
|
|
||||||
c, err := container.runtime.volumes.Create(nil, container, "", "", nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
srcPath, err = c.layer()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
srcRW = true // RW by default
|
|
||||||
}
|
|
||||||
container.Volumes[volPath] = srcPath
|
|
||||||
container.VolumesRW[volPath] = srcRW
|
|
||||||
// Create the mountpoint
|
|
||||||
rootVolPath := path.Join(container.RootfsPath(), volPath)
|
|
||||||
if err := os.MkdirAll(rootVolPath, 0755); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not copy or change permissions if we are mounting from the host
|
if container.Volumes == nil || len(container.Volumes) == 0 {
|
||||||
if srcRW && !isBindMount {
|
container.Volumes = make(map[string]string)
|
||||||
volList, err := ioutil.ReadDir(rootVolPath)
|
container.VolumesRW = make(map[string]bool)
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
|
// Apply volumes from another container if requested
|
||||||
|
if container.Config.VolumesFrom != "" {
|
||||||
|
volumes := strings.Split(container.Config.VolumesFrom, ",")
|
||||||
|
for _, v := range volumes {
|
||||||
|
c := container.runtime.Get(v)
|
||||||
|
if c == nil {
|
||||||
|
return fmt.Errorf("Container %s not found. Impossible to mount its volumes", container.ID)
|
||||||
|
}
|
||||||
|
for volPath, id := range c.Volumes {
|
||||||
|
if _, exists := container.Volumes[volPath]; exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
container.Volumes[volPath] = id
|
||||||
|
if isRW, exists := c.VolumesRW[volPath]; exists {
|
||||||
|
container.VolumesRW[volPath] = isRW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if len(volList) > 0 {
|
}
|
||||||
srcList, err := ioutil.ReadDir(srcPath)
|
|
||||||
|
// Create the requested volumes if they don't exist
|
||||||
|
for volPath := range container.Config.Volumes {
|
||||||
|
volPath = path.Clean(volPath)
|
||||||
|
// Skip existing volumes
|
||||||
|
if _, exists := container.Volumes[volPath]; exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var srcPath string
|
||||||
|
var isBindMount bool
|
||||||
|
srcRW := false
|
||||||
|
// If an external bind is defined for this volume, use that as a source
|
||||||
|
if bindMap, exists := binds[volPath]; exists {
|
||||||
|
isBindMount = true
|
||||||
|
srcPath = bindMap.SrcPath
|
||||||
|
if strings.ToLower(bindMap.Mode) == "rw" {
|
||||||
|
srcRW = true
|
||||||
|
}
|
||||||
|
// Otherwise create an directory in $ROOT/volumes/ and use that
|
||||||
|
} else {
|
||||||
|
c, err := container.runtime.volumes.Create(nil, container, "", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(srcList) == 0 {
|
srcPath, err = c.layer()
|
||||||
// If the source volume is empty copy files from the root into the volume
|
if err != nil {
|
||||||
if err := CopyWithTar(rootVolPath, srcPath); err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
srcRW = true // RW by default
|
||||||
|
}
|
||||||
|
container.Volumes[volPath] = srcPath
|
||||||
|
container.VolumesRW[volPath] = srcRW
|
||||||
|
// Create the mountpoint
|
||||||
|
rootVolPath := path.Join(container.RootfsPath(), volPath)
|
||||||
|
if err := os.MkdirAll(rootVolPath, 0755); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var stat syscall.Stat_t
|
// Do not copy or change permissions if we are mounting from the host
|
||||||
if err := syscall.Stat(rootVolPath, &stat); err != nil {
|
if srcRW && !isBindMount {
|
||||||
|
volList, err := ioutil.ReadDir(rootVolPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(volList) > 0 {
|
||||||
|
srcList, err := ioutil.ReadDir(srcPath)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var srcStat syscall.Stat_t
|
if len(srcList) == 0 {
|
||||||
if err := syscall.Stat(srcPath, &srcStat); err != nil {
|
// If the source volume is empty copy files from the root into the volume
|
||||||
return err
|
if err := CopyWithTar(rootVolPath, srcPath); err != nil {
|
||||||
}
|
|
||||||
// Change the source volume's ownership if it differs from the root
|
|
||||||
// files that where just copied
|
|
||||||
if stat.Uid != srcStat.Uid || stat.Gid != srcStat.Gid {
|
|
||||||
if err := os.Chown(srcPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stat syscall.Stat_t
|
||||||
|
if err := syscall.Stat(rootVolPath, &stat); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var srcStat syscall.Stat_t
|
||||||
|
if err := syscall.Stat(srcPath, &srcStat); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Change the source volume's ownership if it differs from the root
|
||||||
|
// files that where just copied
|
||||||
|
if stat.Uid != srcStat.Uid || stat.Gid != srcStat.Gid {
|
||||||
|
if err := os.Chown(srcPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := container.generateLXCConfig(hostConfig); err != nil {
|
if err := container.generateLXCConfig(hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
params := []string{
|
|
||||||
"-n", container.ID,
|
|
||||||
"-f", container.lxcConfigPath(),
|
|
||||||
"--",
|
|
||||||
"/.dockerinit",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Networking
|
|
||||||
if !container.Config.NetworkDisabled {
|
|
||||||
params = append(params, "-g", container.network.Gateway.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// User
|
|
||||||
if container.Config.User != "" {
|
|
||||||
params = append(params, "-u", container.Config.User)
|
|
||||||
}
|
|
||||||
|
|
||||||
if container.Config.Tty {
|
|
||||||
params = append(params, "-e", "TERM=xterm")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup environment
|
|
||||||
params = append(params,
|
|
||||||
"-e", "HOME=/",
|
|
||||||
"-e", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
||||||
"-e", "container=lxc",
|
|
||||||
"-e", "HOSTNAME="+container.Config.Hostname,
|
|
||||||
)
|
|
||||||
if container.Config.WorkingDir != "" {
|
|
||||||
workingDir := path.Clean(container.Config.WorkingDir)
|
|
||||||
utils.Debugf("[working dir] working dir is %s", workingDir)
|
|
||||||
|
|
||||||
if err := os.MkdirAll(path.Join(container.RootfsPath(), workingDir), 0755); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params := []string{
|
||||||
|
"-n", container.ID,
|
||||||
|
"-f", container.lxcConfigPath(),
|
||||||
|
"--",
|
||||||
|
"/.dockerinit",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Networking
|
||||||
|
if !container.Config.NetworkDisabled {
|
||||||
|
params = append(params, "-g", container.network.Gateway.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// User
|
||||||
|
if container.Config.User != "" {
|
||||||
|
params = append(params, "-u", container.Config.User)
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.Config.Tty {
|
||||||
|
params = append(params, "-e", "TERM=xterm")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup environment
|
||||||
params = append(params,
|
params = append(params,
|
||||||
"-w", workingDir,
|
"-e", "HOME=/",
|
||||||
|
"-e", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
|
"-e", "container=lxc",
|
||||||
|
"-e", "HOSTNAME="+container.Config.Hostname,
|
||||||
)
|
)
|
||||||
|
if container.Config.WorkingDir != "" {
|
||||||
|
workingDir := path.Clean(container.Config.WorkingDir)
|
||||||
|
utils.Debugf("[working dir] working dir is %s", workingDir)
|
||||||
|
|
||||||
|
if err := os.MkdirAll(path.Join(container.RootfsPath(), workingDir), 0755); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
params = append(params,
|
||||||
|
"-w", workingDir,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, elem := range container.Config.Env {
|
||||||
|
params = append(params, "-e", elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Program
|
||||||
|
params = append(params, "--", container.Path)
|
||||||
|
params = append(params, container.Args...)
|
||||||
|
|
||||||
|
container.cmd = exec.Command("lxc-start", params...)
|
||||||
|
|
||||||
|
// Setup logging of stdout and stderr to disk
|
||||||
|
if err := container.runtime.LogToDisk(container.stdout, container.logPath("json"), "stdout"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := container.runtime.LogToDisk(container.stderr, container.logPath("json"), "stderr"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
container.cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if container.Config.Tty {
|
||||||
|
err = container.startPty()
|
||||||
|
} else {
|
||||||
|
err = container.start()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// FIXME: save state on disk *first*, then converge
|
||||||
|
// this way disk state is used as a journal, eg. we can restore after crash etc.
|
||||||
|
container.State.setRunning(container.cmd.Process.Pid)
|
||||||
|
|
||||||
|
// Init the lock
|
||||||
|
container.waitLock = make(chan struct{})
|
||||||
|
|
||||||
|
container.ToDisk()
|
||||||
|
container.SaveHostConfig(hostConfig)
|
||||||
|
go container.monitor(hostConfig)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
err := startFct(hostConfig)
|
||||||
for _, elem := range container.Config.Env {
|
|
||||||
params = append(params, "-e", elem)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Program
|
|
||||||
params = append(params, "--", container.Path)
|
|
||||||
params = append(params, container.Args...)
|
|
||||||
|
|
||||||
container.cmd = exec.Command("lxc-start", params...)
|
|
||||||
|
|
||||||
// Setup logging of stdout and stderr to disk
|
|
||||||
if err := container.runtime.LogToDisk(container.stdout, container.logPath("json"), "stdout"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := container.runtime.LogToDisk(container.stderr, container.logPath("json"), "stderr"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
container.cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
if container.Config.Tty {
|
|
||||||
err = container.startPty()
|
|
||||||
} else {
|
|
||||||
err = container.start()
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
container.cleanup()
|
||||||
}
|
}
|
||||||
// FIXME: save state on disk *first*, then converge
|
return err
|
||||||
// this way disk state is used as a journal, eg. we can restore after crash etc.
|
|
||||||
container.State.setRunning(container.cmd.Process.Pid)
|
|
||||||
|
|
||||||
// Init the lock
|
|
||||||
container.waitLock = make(chan struct{})
|
|
||||||
|
|
||||||
container.ToDisk()
|
|
||||||
container.SaveHostConfig(hostConfig)
|
|
||||||
go container.monitor(hostConfig)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Run() error {
|
func (container *Container) Run() error {
|
||||||
|
@ -981,6 +989,28 @@ func (container *Container) monitor(hostConfig *HostConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
container.cleanup()
|
||||||
|
|
||||||
|
// Re-create a brand new stdin pipe once the container exited
|
||||||
|
if container.Config.OpenStdin {
|
||||||
|
container.stdin, container.stdinPipe = io.Pipe()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release the lock
|
||||||
|
close(container.waitLock)
|
||||||
|
|
||||||
|
if err := container.ToDisk(); err != nil {
|
||||||
|
// FIXME: there is a race condition here which causes this to fail during the unit tests.
|
||||||
|
// If another goroutine was waiting for Wait() to return before removing the container's root
|
||||||
|
// from the filesystem... At this point it may already have done so.
|
||||||
|
// This is because State.setStopped() has already been called, and has caused Wait()
|
||||||
|
// to return.
|
||||||
|
// FIXME: why are we serializing running state to disk in the first place?
|
||||||
|
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (container *Container) cleanup() {
|
||||||
container.releaseNetwork()
|
container.releaseNetwork()
|
||||||
if container.Config.OpenStdin {
|
if container.Config.OpenStdin {
|
||||||
if err := container.stdin.Close(); err != nil {
|
if err := container.stdin.Close(); err != nil {
|
||||||
|
@ -1003,24 +1033,6 @@ func (container *Container) monitor(hostConfig *HostConfig) {
|
||||||
if err := container.Unmount(); err != nil {
|
if err := container.Unmount(); err != nil {
|
||||||
log.Printf("%v: Failed to umount filesystem: %v", container.ID, err)
|
log.Printf("%v: Failed to umount filesystem: %v", container.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-create a brand new stdin pipe once the container exited
|
|
||||||
if container.Config.OpenStdin {
|
|
||||||
container.stdin, container.stdinPipe = io.Pipe()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the lock
|
|
||||||
close(container.waitLock)
|
|
||||||
|
|
||||||
if err := container.ToDisk(); err != nil {
|
|
||||||
// FIXME: there is a race condition here which causes this to fail during the unit tests.
|
|
||||||
// If another goroutine was waiting for Wait() to return before removing the container's root
|
|
||||||
// from the filesystem... At this point it may already have done so.
|
|
||||||
// This is because State.setStopped() has already been called, and has caused Wait()
|
|
||||||
// to return.
|
|
||||||
// FIXME: why are we serializing running state to disk in the first place?
|
|
||||||
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) kill() error {
|
func (container *Container) kill() error {
|
||||||
|
|
Loading…
Reference in New Issue