github.com/nguyentm83/docker@v1.5.0/daemon/pause.go (about)

     1  package daemon
     2  
     3  import (
     4  	"github.com/docker/docker/engine"
     5  )
     6  
     7  func (daemon *Daemon) ContainerPause(job *engine.Job) engine.Status {
     8  	if len(job.Args) != 1 {
     9  		return job.Errorf("Usage: %s CONTAINER", job.Name)
    10  	}
    11  	name := job.Args[0]
    12  	container := daemon.Get(name)
    13  	if container == nil {
    14  		return job.Errorf("No such container: %s", name)
    15  	}
    16  	if err := container.Pause(); err != nil {
    17  		return job.Errorf("Cannot pause container %s: %s", name, err)
    18  	}
    19  	container.LogEvent("pause")
    20  	return engine.StatusOK
    21  }
    22  
    23  func (daemon *Daemon) ContainerUnpause(job *engine.Job) engine.Status {
    24  	if n := len(job.Args); n < 1 || n > 2 {
    25  		return job.Errorf("Usage: %s CONTAINER", job.Name)
    26  	}
    27  	name := job.Args[0]
    28  	container := daemon.Get(name)
    29  	if container == nil {
    30  		return job.Errorf("No such container: %s", name)
    31  	}
    32  	if err := container.Unpause(); err != nil {
    33  		return job.Errorf("Cannot unpause container %s: %s", name, err)
    34  	}
    35  	container.LogEvent("unpause")
    36  	return engine.StatusOK
    37  }