github.com/skf/moby@v1.13.1/daemon/unpause.go (about)

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