'Return the `Name` param from `docker info` to use as the hostname
Falls back to the default route.'

def get_hostname(self, use_default_gw=True, should_resolve=False):

    is_resolvable = (lambda host: socket.gethostbyname(host))
    if (self.hostname is not None):
        try:
            if ((not should_resolve) or is_resolvable(self.hostname)):
                return self.hostname
        except Exception:
            log.debug(("Couldn't    resolve    cached    hostname    %s,    triggering    new    hostname    detection." % self.hostname))
    if ((self._default_gateway is not None) and use_default_gw):
        return self._default_gateway
    try:
        self.hostname = self.client.info().get('Name')
        if ((not should_resolve) or is_resolvable(self.hostname)):
            return self.hostname
    except Exception as e:
        log.debug('Unable    to    retrieve    hostname    using    docker    API,    %s', str(e))
        if (not use_default_gw):
            return None
    log.warning('Unable    to    find    docker    host    hostname.    Trying    default    route')
    self._default_gateway = DockerUtil.get_gateway()
    return self._default_gateway
