Resolve Docker DNS Issue on Server Restart
The Issue
I have been moving over to using Debian 13, and I strongly suspect that this issue is related to this, as I have not been experiencing this issue in the past. When I restart my virtual machines with docker containers running, they are suddenly unable to resolve hosts. They will start up and show as running correctly, which "hides" the problem, but you will end up getting wierd issues such as those services not being able to send emails because they can't resolve the SMTP host. Luckily this problem is easy enough to resolve and the following has been tested against Debian 13 where I experienced the issue.
Steps
Run the following set of commands to configure Docker to start up only after the network is ready before then restarting the service.
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/network-online.conf > /dev/null <<EOF
[Unit]
After=network-online.target
Wants=network-online.target
EOF
# Restart
sudo systemctl daemon-reload
sudo systemctl restart docker
First published: 4th May 2026