github.com/tsuna/docker@v1.7.0-rc3/api/client/wait.go (about) 1 package client 2 3 import ( 4 "fmt" 5 6 flag "github.com/docker/docker/pkg/mflag" 7 ) 8 9 // CmdWait blocks until a container stops, then prints its exit code. 10 // 11 // If more than one container is specified, this will wait synchronously on each container. 12 // 13 // Usage: docker wait CONTAINER [CONTAINER...] 14 func (cli *DockerCli) CmdWait(args ...string) error { 15 cmd := cli.Subcmd("wait", "CONTAINER [CONTAINER...]", "Block until a container stops, then print its exit code.", true) 16 cmd.Require(flag.Min, 1) 17 18 cmd.ParseFlags(args, true) 19 20 var errNames []string 21 for _, name := range cmd.Args() { 22 status, err := waitForExit(cli, name) 23 if err != nil { 24 fmt.Fprintf(cli.err, "%s\n", err) 25 errNames = append(errNames, name) 26 } else { 27 fmt.Fprintf(cli.out, "%d\n", status) 28 } 29 } 30 if len(errNames) > 0 { 31 return fmt.Errorf("Error: failed to wait containers: %v", errNames) 32 } 33 return nil 34 }