knktc's Notes

python, cloud, linux...

0%

Fix Docker Not Starting on Fedora 25 Without a Network Connection

Fedora 25 uses NetworkManager by default. When the machine has no network connection at all, such as no Ethernet cable and no Wi-Fi, NetworkManager may not create /etc/resolv.conf. Docker containers depend on that file for DNS resolution, so in this situation Docker containers can fail to start.

One workaround is to create a small script under /etc/NetworkManager/dispatcher.d/pre-up.d so that resolv.conf exists before the network comes up.

Script content:

1
2
3
#!/bin/sh
touch /var/run/NetworkManager/resolv.conf
touch /etc/resolv.conf

Then make the script executable so it can actually run.

After that, you can test by rebooting the system with the network cable unplugged and Wi-Fi disabled. Because /etc/resolv.conf is created early, Docker containers should still be able to start.

This may also apply to other Linux distributions, though I have not tested it outside Fedora.

如果我的文字帮到了您,那么可不可以请我喝罐可乐?