github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/lib/wait.go (about) 1 package lib 2 3 import ( 4 "encoding/json" 5 6 "github.com/docker/docker/api/types" 7 ) 8 9 // ContainerWait pauses execution util a container is exits. 10 // It returns the API status code as response of its readiness. 11 func (cli *Client) ContainerWait(containerID string) (int, error) { 12 resp, err := cli.post("/containers/"+containerID+"/wait", nil, nil, nil) 13 if err != nil { 14 return -1, err 15 } 16 defer ensureReaderClosed(resp) 17 18 var res types.ContainerWaitResponse 19 if err := json.NewDecoder(resp.body).Decode(&res); err != nil { 20 return -1, err 21 } 22 23 return res.StatusCode, nil 24 }