2015-03-25 06:57:23 +03:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
|
|
)
|
|
|
|
|
2015-03-25 20:34:41 +03:00
|
|
|
// CmdPause pauses all processes within one or more containers.
|
|
|
|
//
|
|
|
|
// Usage: docker pause CONTAINER [CONTAINER...]
|
2015-03-25 06:57:23 +03:00
|
|
|
func (cli *DockerCli) CmdPause(args ...string) error {
|
|
|
|
cmd := cli.Subcmd("pause", "CONTAINER [CONTAINER...]", "Pause all processes within a container", true)
|
|
|
|
cmd.Require(flag.Min, 1)
|
2015-03-29 04:22:46 +03:00
|
|
|
cmd.ParseFlags(args, false)
|
2015-03-25 06:57:23 +03:00
|
|
|
|
2015-05-05 10:59:17 +03:00
|
|
|
var errNames []string
|
2015-03-25 06:57:23 +03:00
|
|
|
for _, name := range cmd.Args() {
|
2015-01-12 22:56:01 +03:00
|
|
|
if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/pause", name), nil, nil)); err != nil {
|
2015-03-25 06:57:23 +03:00
|
|
|
fmt.Fprintf(cli.err, "%s\n", err)
|
2015-05-05 10:59:17 +03:00
|
|
|
errNames = append(errNames, name)
|
2015-03-25 06:57:23 +03:00
|
|
|
} else {
|
|
|
|
fmt.Fprintf(cli.out, "%s\n", name)
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 10:59:17 +03:00
|
|
|
if len(errNames) > 0 {
|
|
|
|
return fmt.Errorf("Error: failed to pause containers: %v", errNames)
|
|
|
|
}
|
|
|
|
return nil
|
2015-03-25 06:57:23 +03:00
|
|
|
}
|