github.com/a4a881d4/docker@v1.9.0-rc2/api/client/pause.go (about) 1 package client 2 3 import ( 4 "fmt" 5 6 Cli "github.com/docker/docker/cli" 7 flag "github.com/docker/docker/pkg/mflag" 8 ) 9 10 // CmdPause pauses all processes within one or more containers. 11 // 12 // Usage: docker pause CONTAINER [CONTAINER...] 13 func (cli *DockerCli) CmdPause(args ...string) error { 14 cmd := Cli.Subcmd("pause", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["pause"].Description, true) 15 cmd.Require(flag.Min, 1) 16 17 cmd.ParseFlags(args, true) 18 19 var errNames []string 20 for _, name := range cmd.Args() { 21 if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/pause", name), nil, nil)); err != nil { 22 fmt.Fprintf(cli.err, "%s\n", err) 23 errNames = append(errNames, name) 24 } else { 25 fmt.Fprintf(cli.out, "%s\n", name) 26 } 27 } 28 if len(errNames) > 0 { 29 return fmt.Errorf("Error: failed to pause containers: %v", errNames) 30 } 31 return nil 32 }