Docker in Docker: send GET request to newly created container is failing

Using Python’s SDK Docker package, I started a container.

I get its IP address using container_address = f"http://{container.attrs['NetworkSettings']['IPAddress']}:80/"

Using the requests package, I tried to get that endpoint.

The following error appears:

HTTPConnectionPool(host='', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f7845af3010>, 'Connection to timed out. (connect timeout=None)'))

The same script works fine locally, meaning that using Docker’s Python SDK I can run a container and do a GET request.

Any ideas why it’s failing in the pipeline?