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.
Source: bytebot-ai/bytebot