unpause.go 980 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package daemon
  2. import (
  3. "fmt"
  4. "github.com/docker/docker/container"
  5. )
  6. // ContainerUnpause unpauses a container
  7. func (daemon *Daemon) ContainerUnpause(name string) error {
  8. container, err := daemon.GetContainer(name)
  9. if err != nil {
  10. return err
  11. }
  12. if err := daemon.containerUnpause(container); err != nil {
  13. return err
  14. }
  15. return nil
  16. }
  17. // containerUnpause resumes the container execution after the container is paused.
  18. func (daemon *Daemon) containerUnpause(container *container.Container) error {
  19. container.Lock()
  20. defer container.Unlock()
  21. // We cannot unpause the container which is not running
  22. if !container.Running {
  23. return errNotRunning{container.ID}
  24. }
  25. // We cannot unpause the container which is not paused
  26. if !container.Paused {
  27. return fmt.Errorf("Container %s is not paused", container.ID)
  28. }
  29. if err := daemon.containerd.Resume(container.ID); err != nil {
  30. return fmt.Errorf("Cannot unpause container %s: %s", container.ID, err)
  31. }
  32. return nil
  33. }