I recently migrated my installation from a hard drive to an SSD using partclone, but now Docker fails to start automatically on boot. I can start it manually with `systemctl start docker.service`, but it throws an error when trying to start on its own. The log (`journalctl -b`) shows that it failed to connect because it couldn't find the local IP address, displaying this message: 'failed to start cluster component: could not find local IP address: dial udp 192.168.0.98:2377: connect: network is unreachable'.
This is a worker node in a swarm, and I confirmed that the manager is at the correct address (192.168.0.98). Although I can reach this IP over SSH and use netcat without issues, I can't figure out why Docker won't launch at startup. The unit file appears to be the standard version provided with Raspbian for the Pi 4. Does anyone have insight into what might need tweaking to resolve this? Thanks!
2 Answers
If adjusting the unit file doesn't work, check your network settings. Sometimes, an IP conflict can cause issues, especially after migration. Double-check your static IP configuration to ensure your device has a fixed IP assigned, which can help avoid these connectivity problems on boot.
It looks like you're having a network issue where Docker can't find the local IP address during startup. Make sure your network is fully up before Docker tries to start. You might want to adjust your Docker service file to add a dependency on the network being fully wired up. One way to do this is by modifying the `After` line in your unit file to include `network-online.target` and adding `Wants=network-online.target` if it's not already there.
I think you might need to enable the `systemd-networkd-wait-online.service` too, so that your system waits for the network before launching any services like Docker.
Yeah, I had a similar issue where my Pi picked a different IP after a reboot. Setting a static IP for your device in your router settings or through DHCP reservations can really help.