When incus was first announced i played around with it extensively to see if it can be a 1:1 replacement for my jailmaker nspawn-container which hosts my docker stack. One of the docker container i run in there is blocky, a dns-sinkhole like pi-hole which also needs port 53. I then googled around and found the command i posted in this tread above in a post on the incus forum.
So basically i’ve been in the same position 6 months ago
I just did the upgrade from 25.04 to 25.10, now that it is considered stable, and I had to run this command again to get Pihole working again. At least it was an easy fix.
Seeing as I had to redo this when I did the 25.10 upgrade, i’m presuming that this will revert with all upgrades (or at least significant ones), here’s a script to inject the incus networkcommand into the /etc/init.d/docker file so it will run on start of the docker service
#!/usr/bin/bash
set -e
PORT_TO_SET=5354
if [ "$(id -u)" != '0' ]; then
echo "Must be run as root"
exit 1
fi
function getThePort () {
local portString
portString=$(incus network get incusbr0 raw.dnsmasq || true | grep -oP 'port=\K\d+')
echo "${portString#port=}"
}
thePort=$(getThePort)
initd=/etc/init.d/docker
if [[ ! -f "$initd" ]]; then
echo "Docker init script not found at $initd. Exiting."
exit 1
fi
if [[ -z "$thePort" ]]; then
echo "No port found in incusbr0 configuration. Setting to default $PORT_TO_SET."
thePort=$PORT_TO_SET
doSet=true
elif [[ "$thePort" -ne "$PORT_TO_SET" ]]; then
echo "Current DNS port is $thePort. Updating to $PORT_TO_SET."
doSet=true
else
echo "Port is already set to $PORT_TO_SET. No changes needed."
doSet=false
fi
cmdOpen="incus network set incusbr0 raw.dnsmasq="
theCmd="${cmdOpen}\"port=$PORT_TO_SET\""
lineExists=$(grep -c "$cmdOpen" "$initd" || true)
if [[ "$doSet" == true || "$lineExists" -eq 0 ]]; then
echo "Setting DNS port to $PORT_TO_SET."
if [[ "$doSet" == true ]]; then
# do it now
eval "$theCmd"
echo "DNS port updated to $PORT_TO_SET."
fi
# Inject the command into the init script before the start-stop-daemon line
sed -i "/$cmdOpen/d" "$initd"
sed -i "/start-stop-daemon --start/i\\ $theCmd" "$initd"
echo "Injected command into $initd before start-stop-daemon line."
fi
also available as a github gist at https://gist.github.com/itsalljustdata/aff96c558b40f026fa5c572252e31ee9