Wait for a container to have a State.Running value = true.
    :param hosts: list of service names taken from container.yml
    :param max_attempts: Max number of times to inspect the container and check State.Running
    :param sleep_time: Number of seconds to wait between attempts.
    :return: dict of host:running pairs

def wait_on_hosts(hosts, max_attempts=3, sleep_time=1):
    '''
    Wait for a container to have a State.Running value = true.
    :param hosts: list of service names taken from container.yml
    :param max_attempts: Max number of times to inspect the container and check State.Running
    :param sleep_time: Number of seconds to wait between attempts.
    :return: dict of host:running pairs
    '''
    results = {}
    for host in hosts:
        container = "ansible_{}_1".format(host)
        tries = max_attempts
        host_ready = False
        output = None
        results[host] = False
        while tries > 0 and not host_ready:
            try:
                output = subprocess.check_output(["docker", "inspect", "--format", "{{ .State.Running }}",
                                                  container], stderr=STDOUT)
            except CalledProcessError:
                pass
            tries -= 1
            if output and 'true' in output:
                host_ready = True
                results[host] = True
            else:
                sleep(sleep_time)
    return results