Avahi container start script
Start Avahi inside a container for mDNS service discovery, for example to find a PlutoSDR.
avahicontainer_start starts the Avahi service inside an RF Swift container. Avahi provides zeroconf (mDNS) service discovery, which some devices rely on to be found on the network, the PlutoSDR in particular.
Run it when:
- you work with a PlutoSDR or another device found through network service discovery;
- a tool needs mDNS (multicast DNS) or service discovery;
- you see “Avahi daemon not running” or a similar error.
# Inside your RF Swift container
avahicontainer_startWhat the script does
The script lives in /usr/sbin. It:
- creates the
/var/run/dbusdirectory if it does not exist; - starts the D-Bus system daemon in the background;
- waits 2 seconds so D-Bus is fully up;
- starts the Avahi daemon in daemon mode (
-D).
Check that it works
Look for the Avahi process, then list the services it sees:
# Check if Avahi is running
ps aux | grep avahi
# Test service discovery
avahi-browse -aExample: finding a PlutoSDR
Start Avahi, give the services a moment to register, then look for IIO devices:
# Start Avahi service
avahicontainer_start
# Wait a moment for services to register
sleep 2
# Find PlutoSDR on the network
iio_info -s
# Should show something like:
# Available IIO contexts:
# Context 0: ip:pluto.localTroubleshooting
The device is still not found
Check the network mode. The container must use the host network, which is RF Swift’s default. The summary printed by rfswift container shell -c <name> shows the network mode.
Check the firewall. Multicast DNS uses UDP port 5353; make sure it is not blocked:
# Check if multicast traffic is allowed
sudo iptables -L | grep 5353Check for a second Avahi. Conflicts can happen when the host also runs Avahi. Stop the host’s Avahi for a moment to test:
# On your host system, temporarily stop Avahi if needed
sudo systemctl stop avahi-daemonAdvanced usage
Start Avahi with the container
Run the script as the container’s command, followed by a shell:
rfswift container create -i sdr_full -n pluto_container -e "avahicontainer_start && /bin/bash"Advertise your own services
Add a service file to advertise a service of your own, then restart Avahi:
# Create a custom service file
cat > /etc/avahi/services/myservice.service << EOF
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name>MyCustomService</name>
<service>
<type>_myservice._tcp</type>
<port>12345</port>
</service>
</service-group>
EOF
# Restart Avahi to apply
avahi-daemon -r