I am working on a project where I need to bridge the local network of my host computer to a Docker container. The container needs to be able to communicate with other devices on the same local network as the host machine.
Here are the specifics of my setup:
Host OS: Windows
Docker version: 4.29.0
Network configuration: IP in docker conterner 192.168.65.6 192.168.65.3 172.17.0.1 172.18.0.1, local ip 192.168.0.112 (gateway 192.168.0.1)
Any help or pointers would be greatly appreciated.
I have tried using the –network host option, but it does not seem to provide the desired functionality for my use case. The container needs to appear as if it is part of the local network, with its own IP address that other devices on the network can directly communicate with.
What are the best practices or configurations to achieve this? Are there any specific Docker network modes or additional tools I should use?
Ksez0 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What are the best practices
There are no best practices. It is an unusual practice.
or configurations to achieve this?
The container needs to appear as if it is part of the local network, with its own IP address
What basically you have to do, is to assign two IP addresses to your host hardware interface connected to the local network.
Then you have to write an intricate iptables routing rules so that the second IP address is routed to the docker container address with some masquerading. And also that the first IP address is not handled by anything on the host. I am not sure how to exclude an IP address from binding to 0.0.0.0
.
Are there any specific Docker network modes
No.
or additional tools I should use?
iptables, nftables, ip