I'm trying to configure a static IP address for a docker machine.
Thanks to VonC answer, I managed to get started.
However, I'm facing a problem: boot2docker seems to ignore the "route add default gw 192.168.0.1", no matter what.
To reproduce:
1. Create a new docker machine: OK
docker-machine create -d hyperv --hyperv-virtual-switch "Primary Virtual Switch" Swarm-Worker1
2. Apply your batch: OK
dmvbf Swarm-Worker1 0 108
3. SSH into the machine and check that bootsync.sh is fine: OK
cat /var/lib/boot2docker/bootsync.sh
output:
kill $(more /var/run/udhcpc.eth0.pid)
ifconfig eth0 192.168.0.108 netmask 255.255.255.0 broadcast 192.168.0.255 up
route add default gw 192.168.0.1
4. Exit SSH, restart the machine then regenerate certs: OK
docker-machine restart Swarm-Worker1
docker-machine regenerate-certs Swarm-Worker1
5. Check that the IP matches the desired one: OK
docker-machine env Swarm-Worker1
6: SSH into the machine and check its routes: KO
route -n
output:
127.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 lo
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
7: Try to set the gateway manually and check if it works: OK
route add default gw 192.168.0.1
OR
ip route add default via 192.168.0.1
Anyone knows what's happening? Why would boot2docker ignore only the route instruction? How can I solve that?
P.S: My docker-machines run on Docker-Engine - Community 18.09.6