github.com/vincentwoo/docker@v0.7.3-0.20160116130405-82401a4b13c0/daemon/unpause.go (about) 1 package daemon 2 3 import ( 4 "github.com/docker/docker/container" 5 derr "github.com/docker/docker/errors" 6 ) 7 8 // ContainerUnpause unpauses a container 9 func (daemon *Daemon) ContainerUnpause(name string) error { 10 container, err := daemon.GetContainer(name) 11 if err != nil { 12 return err 13 } 14 15 if err := daemon.containerUnpause(container); err != nil { 16 return derr.ErrorCodeCantUnpause.WithArgs(name, err) 17 } 18 19 return nil 20 } 21 22 // containerUnpause resumes the container execution after the container is paused. 23 func (daemon *Daemon) containerUnpause(container *container.Container) error { 24 container.Lock() 25 defer container.Unlock() 26 27 // We cannot unpause the container which is not running 28 if !container.Running { 29 return derr.ErrorCodeNotRunning.WithArgs(container.ID) 30 } 31 32 // We cannot unpause the container which is not paused 33 if !container.Paused { 34 return derr.ErrorCodeNotPaused.WithArgs(container.ID) 35 } 36 37 if err := daemon.execDriver.Unpause(container.Command); err != nil { 38 return err 39 } 40 41 container.Paused = false 42 daemon.LogContainerEvent(container, "unpause") 43 return nil 44 }