Hey everyone! Today, I want to share a recent challenge I faced while setting up Pi.Alert in a Docker container. My goal was to get a better handle on the plethora of devices buzzing around our LAN, but I ran into a snag.

The first small hurdle was that the network of the Docker container had to be set to host network mode. I’ve never had to deal with this before. But it also makes sense when you consider that the container is supposed to do ARP scans etc. In host mode, the container’s network stack is not isolated from the host and no NAT is done. Basically, it’s like starting an application directly on the host.

To make the ARP scan work, I configured the network mask and interface in the pialert.conf file.

pialert.conf:

# ARPSCAN
#---------------------------
SCAN_SUBNETS=['192.168.178.0/24 --interface=ens160']

The Issue

After Pi.Alert basically worked, a large number of devices were still showing up as “(name not found)” in Pi.Alert. After some digging, I realized the issue was with the /etc/resolv.conf file inside the container. It only had localhost defined (127.0.0.1).

The Fix

To tackle this, I configured a custom /etc/resolv.conf file in the docker-compose.yml and set the DNS server of my LAN (Pi-Hole) as the nameserver. This change changed everything, and soon most systems were showing up correctly with their DNS names.

Here’s how I did it:

docker-compose.yml:

version: "3"
services:
  pialert:
    container_name: pialert
    image: "jokobsk/pi.alert:latest"
    restart: unless-stopped
    volumes:
      - ./config/pialert.conf:/home/pi/pialert/config/pialert.conf
      - ./pialert_db:/home/pi/pialert/db
      - ./setting_darkmode:/home/pi/pialert/db/setting_darkmode
      - ./log:/home/pi/pialert/front/log
      - ./config/resolv.conf:/etc/resolv.conf
    environment:
      - TZ=Europe/Berlin
      - PORT=20211
      - HOST_USER_ID=1000
      - HOST_USER_GID=1000
    ports:
      - "20211:20211"
    network_mode: host

./config/resolv.conf:

nameserver 192.168.178.11
options edns0 trust-ad
search example.com

Conclusion

This simple but effective solution not only solved the problem with the DNS name, but also made the whole project usable in the first place. I wonder why this is not mentioned in the Pi.Alert documentation. Because this was my second attempt with it. The first time I just wondered about it and thought the whole project wasn’t ready and scrapped it.

If you set up Pi.Alert or any other network-dependent container, remember to check your DNS settings ;-)

Happy networking!