In version 4.34.0, host networking support for mac went GA. This feature starts failing with a large number of ports (maxing out at 18 consistently using the example in this issue). It fails a bit inconsistently. In testing with our actual project, once we pass a certain threshold, all ports stop responding from the host (but the services still respond testing from inside the container). When creating a minimal test case to file an issue, more often what I see is that a subset of the ports stop responding from the host. I was able to reproduce this same behavior on a colleague's computer.
Reproduce
Run compose file specified below. The threshold where things start to have problems seems to be around ~20
docker compose --file compose-bug.yaml up
See that not all containers are responding. You could do this manually, but this is a the script I used:
import http.client
for i in range(1, 21):
port = 8000 + i
conn = http.client.HTTPConnection("localhost", port)
try:
conn.request("GET", "/")
response = conn.getresponse()
print(f"Response from localhost:{port}: {response.status}")
except Exception as e:
print(f"Error connecting to localhost:{port}: {e}")
finally:
conn.close()
Here's some sample output:
Response from localhost:8001: 200
Response from localhost:8002: 200
Response from localhost:8003: 200
Error connecting to localhost:8004: [Errno 61] Connection refused
Response from localhost:8005: 200
Response from localhost:8006: 200
Response from localhost:8007: 200
Response from localhost:8008: 200
Response from localhost:8009: 200
Response from localhost:8010: 200
Response from localhost:8011: 200
Response from localhost:8012: 200
Response from localhost:8013: 200
Error connecting to localhost:8014: [Errno 61] Connection refused
Response from localhost:8015: 200
Response from localhost:8016: 200
Response from localhost:8017: 200
Response from localhost:8018: 200
Response from localhost:8019: 200
Response from localhost:8020: 200
network_mode didn't work for 4 and 14 here, but other runs would result in different failures. They do work from the inside:
root@docker-desktop:/# curl -I localhost:8004
HTTP/1.0 200 OK
...
Description
In version 4.34.0, host networking support for mac went GA. This feature starts failing with a large number of ports (maxing out at 18 consistently using the example in this issue). It fails a bit inconsistently. In testing with our actual project, once we pass a certain threshold, all ports stop responding from the host (but the services still respond testing from inside the container). When creating a minimal test case to file an issue, more often what I see is that a subset of the ports stop responding from the host. I was able to reproduce this same behavior on a colleague's computer.
Reproduce
docker compose --file compose-bug.yaml up
See that not all containers are responding. You could do this manually, but this is a the script I used:
Here's some sample output:
network_mode
didn't work for 4 and 14 here, but other runs would result in different failures. They do work from the inside:Compose file:
Expected behavior
network_mode
works for all ports when a large number are used, not just a subset.docker version
docker info
Diagnostics ID
Skipped, this repros in colleagues computers as well, not specific to my install
Additional Info
No response