@David Maze
I came here for the exact same question/problem like initially asked for. But didn't try anything before, so having default configs/setup (networks) on my mac.
Thank you very much for your first answer, helped a lot for further understanding.
But as you described like it should work out of the box here:
Docker provides a network address translation (NAT) mechanism, so containers that make outbound calls mostly look like they're calling from the host system, and generally can reach all of the same places the host system can.
It unfortunately does not on my machine.
Any idea what could be wrong here?
curl on host:
curl --connect-timeout 5 -I 192.168.2.216
HTTP/1.1 200 OK
Content-Type: text/html
Accept-Ranges: bytes
ETag: "4162515329"
Last-Modified: Sun, 29 Dec 2024 15:48:09 GMT
Content-Length: 303
Date: Sat, 25 Jan 2025 14:29:08 GMT
Server: lighttpd/1.4.52-devel-lighttpd-1.4.52
And curl by container:
docker run --rm -it jonlabelle/network-tools curl --connect-timeout 5 -I 192.168.2.216
curl: (28) Connection timed out after 5003 milliseconds
Additionally I have also tried to to run it by a docker-compose file. But still no access to the local network:
docker-compose.yaml:
services:
curl-test:
image: jonlabelle/network-tools
command: curl --connect-timeout 10 -I 192.168.2.216
Result:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:30 --:--:-- 0
curl: (28) Connection timed out after 10003 milliseconds