Linux Docker container cannot connect to host service despite correct network configuration
## Bug Report
System Information:
- OS: Ubuntu (Linux)
- **Docker Version:**Docker version 28.4.0
Problem Description: A Docker container cannot establish a network connection to a service running on the host machine, even when all configurations appear correct. This prevents Bytebot from connecting to a local Ollama instance.
Evidence:
-
Ollama service is working correctly on the host: The command
curl http://localhost:11434/api/tagsrun directly on the host machine succeeds and returns the correct list of models. -
Ollama is listening on all network interfaces: The command
sudo ss -tulpn | grep ollamashows that the service is listening on*:11434(or0.0.0.0:11434), which is correct. -
Connection from a Docker container fails: A definitive test using a network-troubleshooting container (
nicolaka/netshoot) fails. The commandcurl http://172.17.0.1:11434/api/tags(where172.17.0.1is the host's IP on thedocker0bridge) results in a connection timeout error:curl: (28) Failed to connect to 172.17.0.1 port 11434... Could not connect to server.
Troubleshooting Steps Performed: This issue persists even after:
- Configuring Docker's DNS in
/etc/docker/daemon.json. - Temporarily disabling the
ufwfirewall. - Verifying all application-level configurations (
.env,docker-compose.yml). - Attempting to use both Docker's bridge network and
network_mode: host.
Conclusion: There appears to be a fundamental network block between the Docker networking stack and the host system that is preventing container-to-host communication.
Is this specific to Ollama or other network configs? I can verify that the Docker containers can connect to other host services, it's how we develop the bytebot-agent locally.
Is this specific to Ollama or other network configs? I can verify that the Docker containers can connect to other host services, it's how we develop the
bytebot-agentlocally.
Hey@atupem ,Sorry for the delay I ran the test you asked for.
I spun up a simple Python server on my machine, and then tried to hit it from inside a netshoot container.
It failed with the same timeout error. So yeah, it looks like no container can connect to any service on my computer, not just Ollama.
Hope this helps track down the problem!