Connection aborted when unit test to request to docker container built in python Connection aborted when unit test to request to docker container built in python docker docker

Connection aborted when unit test to request to docker container built in python


The right test looks like,

def test_port(docker_image):    image, client = docker_image    import time    container = client.containers.run("python-test:latest",                                      detach=True,                                      ports={'8000/tcp': ('127.0.0.1', 8000)})    time.sleep(1)    resp = requests.get("http://127.0.0.1:8000/hello")    container.kill()    assert resp.status_code == 200