'Block until a container stops, then return its exit code. Similar to
the ``docker wait`` command.
Args:
container (str or dict): The container to wait on. If a dict, the
``Id`` key is used.
timeout (int): Request timeout
Returns:
(int): The exit code of the container. Returns ``-1`` if the API
responds without a ``StatusCode`` attribute.
Raises:
:py:class:`requests.exceptions.ReadTimeout`
If the timeout is exceeded.
:py:class:`docker.errors.APIError`
If the server returns an error.'

@utils.check_resource('container')
def wait(self, container, timeout=None):

    url = self._url('/containers/{0}/wait', container)
    res = self._post(url, timeout=timeout)
    self._raise_for_status(res)
    json_ = res.json()
    if ('StatusCode' in json_):
        return json_['StatusCode']
    return (-1)
