'Attempt to stop the given container.
There is a race condition between a process dying and
Docker noticing that fact:
https://github.com/docker/docker/issues/5165#issuecomment-65753753
If we get an error indicating that this race condition happened,
return False. This means the caller should try again. If we *do*
successfully stop the container, return True.
:raise APIError: If the container failed to stop for some unknown
reason.
:return: True if we stopped the container, False otherwise.'

def _stop_container(self, container_name):

    try:
        with start_action(action_type='flocker:docker:container_stop', container=container_name):
            self._client.stop(container_name)
    except APIError as e:
        if (e.response.status_code == NOT_FOUND):
            return True
        elif (e.response.status_code == INTERNAL_SERVER_ERROR):
            return False
        else:
            raise
    return True
