client/container_wait.go
7c36a1af
 package client
 
 import (
 	"encoding/json"
 
 	"golang.org/x/net/context"
 
181562c2
 	"github.com/docker/docker/api/types/container"
7c36a1af
 )
 
 // ContainerWait pauses execution until a container exits.
 // It returns the API status code as response of its readiness.
181562c2
 func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int64, error) {
7c36a1af
 	resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil)
 	if err != nil {
 		return -1, err
 	}
 	defer ensureReaderClosed(resp)
 
181562c2
 	var res container.ContainerWaitOKBody
7c36a1af
 	if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
 		return -1, err
 	}
 
 	return res.StatusCode, nil
 }