The issue you're experiencing with networkd-dispatcher frequently reporting unknown network interfaces is likely related to the dynamic network environment created by Docker Swarm. Docker, especially when using Swarm, creates and removes many network interfaces as it manages containers and services, which may cause issues for networkd-dispatcher.
Here's a set of steps and considerations to mitigate the problem:
1. [Optional] Disable networkd-dispatcher
If networkd-dispatcher isn't critical for your use case, you might consider disabling it, especially if Docker is heavily modifying network interfaces and it's causing problems.
sudo systemctl disable networkd-dispatcher
sudo systemctl stop networkd-dispatcher
2. Adjust networkd-dispatcher Configuration
There may be a way to adjust the configuration or behavior of networkd-dispatcher to better handle Docker's dynamic interface changes:
Ignore Docker Interfaces
You can modify networkd-dispatcher to ignore Docker interfaces by editing or creating rules. This isn't straightforward because networkd-dispatcher doesn't have built-in support to ignore interfaces based on patterns, but you can use workarounds in the dispatcher scripts.
Custom Scripts
Modify or create scripts in /usr/lib/networkd-dispatcher/routable.d or /etc/networkd-dispatcher/routable.d to ignore docker interfaces:
Example /usr/lib/networkd-dispatcher/routable.d/99-ignore-docker.sh:
#!/bin/bash
INTERFACE=$1
if [[ "$INTERFACE" == "docker"* || "$INTERFACE" == "veth"* ]]; then
exit 0
fi
# Continue with the default action
Make the script executable:
sudo chmod +x /usr/lib/networkd-dispatcher/routable.d/99-ignore-docker.sh
3. Update Docker Network Configuration
Review and tune Docker Swarm network configuration. Excessive creation and deletion of networks and interfaces might be managed or throttled.
4. Check Docker and Systemd Version
Ensure that both Docker and systemd are up-to-date. Sometimes bugs are resolved in newer versions.
Update Docker:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Update Systemd (if applicable):
sudo apt-get update
sudo apt-get upgrade
5. Monitoring and Logging
While you work on a solution, monitoring interface events might help. Capture detailed logs providing insights:
sudo journalctl -u networkd-dispatcher -f
sudo journalctl -u systemd-networkd -f
Collate Logs
Combine various system logs to create a holistic view of what might be causing interface churn:
sudo journalctl | grep -E 'networkd|docker'
Summary
The frequent appearance of these errors is indicative of networkd-dispatcher struggling to deal with rapidly changing network interfaces, especially with Docker Swarm. Disabling networkd-dispatcher, properly configuring it to ignore Docker interfaces if it must remain enabled, and ensuring that both Docker and systemd are updated are all potential steps you can take to mitigate the flood of errors.