Skip to content

Docker & Headless Hardening

headless-phone builds a first-class Docker environment straight into the kernel (kernel/headless.fragment) and Debian 13 rootfs (INSTALL_DOCKER=1).

Every release image ships with docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, and docker-compose-plugin configured with /etc/apt/sources.list.d/docker.sources so sudo apt update && sudo apt upgrade keeps Docker current on-device.

  • Kernel features baked in (=y): Full container namespaces (PID_NS, USER_NS, IPC_NS, UTS_NS, NET_NS, SYSVIPC), unified cgroups v2 (systemd.unified_cgroup_hierarchy=1, CGROUP_BPF, CGROUP_PIDS, CFS_BANDWIDTH), OverlayFS, nftables / iptables-nft + IPVS + IPv4/IPv6 NAT, BRIDGE_NETFILTER, VXLAN, MACVLAN, IPVLAN, and SECCOMP_FILTER.
  • Non-root Docker access: The default user (pixel, or your custom cloud-init admin user) is automatically added to the docker group.

Verify Docker health anytime:

Terminal window
docker info --format 'Cgroup={{.CgroupDriver}} v{{.CgroupVersion}} Storage={{.Driver}} Kernel={{.KernelVersion}}'
docker compose version

Exposing Phone Hardware to Containers Safely

Section titled “Exposing Phone Hardware to Containers Safely”

Rather than passing --privileged, prefer either host IPC bridges (like Frigate’s ZMQ TPU bridge and loopback RTSP publisher) or narrow device passthrough:

Capability Recommended Container Pattern
Edge TPU / Cameras / MFC Keep tpu-ctl serve or camera-ctl in a host systemd unit and bind-mount a 0600 Unix socket (or loopback TCP) into an unprivileged container.
ARM64 KVM virtual machines Pass --device /dev/kvm (/dev/kvm is 0660 root:kvm).
USB serial / Zigbee / Thread dongles Pass --device /dev/serial/by-id/... (plugged into your USB-C dock/hub).
Unprivileged ICMP ping in containers Already enabled host-wide via /etc/sysctl.d/90-headless-phone.conf (net.ipv4.ping_group_range = 0 2147483647).

The base image already locks the root password (passwd -l root), sets PermitRootLogin no and KbdInteractiveAuthentication no, strips SSH host keys and /etc/machine-id before flashing, and enables a 30-second hardware watchdog. For internet-facing or production LAN deployments, follow this checklist:

If you didn’t pass --disable-password-auth at flash time, add your public key first, verify key login in a second terminal, and then disable password authentication via an early drop-in (OpenSSH uses first-match-wins, so 00-* overrides both 50-cloud-init.conf and 90-headless-phone.conf):

Terminal window
sudo tee /etc/ssh/sshd_config.d/00-key-only.conf >/dev/null <<'EOF'
PasswordAuthentication no
EOF
sudo sshd -t && sudo systemctl reload ssh
sudo sshd -T | grep -i passwordauthentication # should print: passwordauthentication no

Also change or lock the default pixel password (passwd pixel or sudo passwd -l pixel if you don’t need serial ttyGS0 password login).

2. Enable a Docker-Safe nftables Host Firewall

Section titled “2. Enable a Docker-Safe nftables Host Firewall”

nftables is preinstalled and kernel-supported.

Instead, confine host-input rules to a dedicated table (table inet headless_host) that never flushes Docker’s tables or touches the forward hook:

/etc/nftables.d/headless-host.nft
table inet headless_host
flush table inet headless_host
table inet headless_host {
chain input {
type filter hook input priority 0; policy drop;
iif "lo" accept
ct state established,related accept
ct state invalid drop
# ICMP / ICMPv6 (ping, PMTU, IPv6 neighbor discovery)
ip protocol icmp accept
ip6 nexthdr icmpv6 accept
# SSH + mDNS
tcp dport 22 accept
udp dport 5353 accept
# Optional: uncomment if running Frigate NVR (HTTPS UI + WebRTC)
# tcp dport { 8971, 8555 } accept
# udp dport 8555 accept
}
}

Validate syntax before loading, then apply with a dedicated oneshot unit ordered after docker.service:

Terminal window
sudo mkdir -p /etc/nftables.d
# (write /etc/nftables.d/headless-host.nft above)
sudo nft -c -f /etc/nftables.d/headless-host.nft
sudo nft -f /etc/nftables.d/headless-host.nft
/etc/systemd/system/headless-firewall.service
[Unit]
Description=Load Docker-safe headless-phone host input firewall
After=network-pre.target docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/nft -f /etc/nftables.d/headless-host.nft
ExecReload=/usr/sbin/nft -f /etc/nftables.d/headless-host.nft
ExecStop=/usr/sbin/nft delete table inet headless_host
[Install]
WantedBy=multi-user.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable --now headless-firewall.service

3. Monitor Power & Thermals with Prometheus

Section titled “3. Monitor Power & Thermals with Prometheus”

Combine power-metrics with a systemd timer writing atomically to prometheus-node-exporter’s textfile collector:

/etc/systemd/system/headless-power-prom.service
[Unit]
Description=Export headless-phone ODPM and battery metrics for Prometheus
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/power-metrics --interval 5 --prom-file /var/lib/prometheus/node-exporter/headless_power.prom
/etc/systemd/system/headless-power-prom.timer
[Unit]
Description=Collect headless-phone ODPM power metrics every 30s
[Timer]
OnBootSec=30s
OnUnitActiveSec=30s
[Install]
WantedBy=timers.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable --now headless-power-prom.timer
  • Debian & Docker security updates: Install unattended-upgrades (sudo apt install unattended-upgrades) or run sudo apt update && sudo apt upgrade periodically.
  • Kernel & headless-phone overlay updates: Run os-upgrade check and sudo os-upgrade apply --release latest --dry-run before applying over SSH. See On-Device OTA Updates.