Couple of weeks ago, I bought Raspberry Pi 5 and use it as my home server (currently only for entertainment and database). And this raspi5 live in my internal home network with IP 192.168.100.100. I can access it easily through my Linux, Windows, and Mac machine.
After updating Docker Desktop, I found that my docker containers can no longer access devices on my local network (e.g., 192.168.100.100
). After doing some research, this is because Docker Desktop runs containers inside a VM, which is isolated from physical LAN — especially on macOS (I’m using Mac Mini M4 btw).
In this post, I’ll show how to work around this limitation using a simple but powerful tool: socat
.
On macOS, Docker runs in a VM that uses NAT networking. This means:
ping 8.8.8.8
)192.168.100.100
)I can make my Mac Mini act as a bridge between the container and LAN using socat
, a lightweight TCP proxy.
Access a MariaDB server running on 192.168.100.100:3306
from inside a Docker container.
socat
on macOS$ brew install socat
$ socat TCP-LISTEN:33060,fork TCP:192.168.100.100:3306
This tells socat to listen on my Mac port 33060 and forward the traffic to MariaDB server on my LAN.
You can try to connect from container like this
$ mysql -h host.docker.internal -P 33060 -u root -p
Thanks for stopping by. This post is honestly for my personal note, hope this helps. See ya