I’m running Docker Desktop v4.34.2 (167172) - and was trying out the (relatively) new host networking support. Observed a situation where some clients had issues connecting to the server (running in docker), and after a bit of troubleshooting distilled it down to the following reproducing example:
On the “server” (running in docker using --network=host
) I spawn 20 listener processes, listening to ports N - N+19
. Then I start (on the host itself) 20 clients, each connecting to one of the server ports. The expected outcome would be that each client connects and then gracefully close the connection. However, only the first 18 of the clients (and this number is consistent!) succeed. The last 2 clients fail with econnrefused
as if the listener is not active. No indication of an issue on the server-side; the call to open a the TCP-listener is successful and there are no errors.
The image is a bog standard alpine-image. If the server is started without --network=host
but with the ports being explicitly mapped the test works as expected. Is there a (known) limitation in the host networking support limiting the number of active sockets? If so 18 seems a bit low (and a weird number), is there a way to work around this?