0

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

Booster2ooo
  • 1,373
  • 9
  • 11
  • Maybe relevant: https://github.com/boot2docker/boot2docker/issues/1364#issuecomment-442324498 and subsequent comments in that issue. – VonC Jun 21 '19 at 09:51
  • Woudl following https://github.com/boot2docker/boot2docker/issues/129#issuecomment-306761261 help? – VonC Jun 21 '19 at 09:53
  • @VonC I'm not sure those are relevant, maybe I'm missing something. If I add the route/ip route command for defining the default gateway to bootsync.sh, it seems to be ignored. But if I type the exact same line manually after the boot, it seem to work fine. I was wondering if maybe something else in the process would overwrite my bootsync.sh route definition later on for instance or if I missed something in the way bootsync.sh should be written ... – Booster2ooo Jun 21 '19 at 13:20
  • The second link I mentioned should help: https://github.com/boot2docker/boot2docker/issues/129: you start the machine once, modify the `bootsync.sh`, stop, restart. – VonC Jun 21 '19 at 14:02
  • You can try and add echos, to check in the syslog how the bootsync.sh fares. – VonC Jun 21 '19 at 14:03

0 Answers0