github.com/gravitational/moby@v1.13.1/client/container_wait.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "golang.org/x/net/context" 7 8 "github.com/docker/docker/api/types/container" 9 ) 10 11 // ContainerWait pauses execution until a container exits. 12 // It returns the API status code as response of its readiness. 13 func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int64, error) { 14 resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil) 15 if err != nil { 16 return -1, err 17 } 18 defer ensureReaderClosed(resp) 19 20 var res container.ContainerWaitOKBody 21 if err := json.NewDecoder(resp.body).Decode(&res); err != nil { 22 return -1, err 23 } 24 25 return res.StatusCode, nil 26 }