'The ECS agent runs on a container and listens to port 51678
We\'ll test the response on / for detection'

def _detect_agent(self):

    urls = []
    ecs_config = self.docker_util.inspect_container('ecs-agent')
    ip = ecs_config.get('NetworkSettings', {}).get('IPAddress')
    if ip:
        ports = ecs_config.get('NetworkSettings', {}).get('Ports')
        port = (ports.keys()[0].split('/')[0] if ports else str(ECS_AGENT_DEFAULT_PORT))
        urls.append(('http://%s:%s/' % (ip, port)))
    gw = self.docker_util.get_gateway()
    if gw:
        urls.append(('http://%s:%d/' % (gw, ECS_AGENT_DEFAULT_PORT)))
    urls.append(('http://localhost:%d/' % ECS_AGENT_DEFAULT_PORT))
    url = self._try_urls(urls, validation_lambda=ECSUtil.ecs_agent_validation)
    if url:
        self.log.debug(('Found    ECS    agent    at    ' + url))
    else:
        self.log.debug(('Could    not    find    ECS    agent    at    urls    ' + str(urls)))
    return url
