devplayer0 / docker-net-dhcp

Docker network driver for networking on a host bridge with DHCP-allocated IP addresses
GNU General Public License v3.0
202 stars 55 forks source link

Support 'gateway' option when creating network #32

Open Vigilans opened 2 years ago

Vigilans commented 2 years ago

When using docker to build an intermediate gateway (like raspberry pi), we may expect a following workflow:

However, currently docker-net-dhcp will always use DHCP published gateway when creating the container, and when that published IP is the same as container's lease IP, an error Destination unreachable will raise, preventing us to modify the gateway later after the container created.

Thus, this PR add a new option gateway when creating the docker network, to forcibly uses a user-provided gateway instead of one provided by DHCP when creating the container.

Usage example: docker create .... -o bridge=br-eth -o gateway=192.168.0.2