📣 Self-Hosted ntfy Server with Docker for Smart Notifications

Staying informed about what’s happening across my home lab and systems is critical. Rather than relying on a bunch of emails or third-party push services, I host my own lightweight notification service using ntfy. It's open-source, flexible, and dead-simple to set up with Docker.

In this post, I'll walk through:

  • How I run ntfy with Docker
  • Why I chose to self-host notifications
  • How I use it in real-world tasks: from system alerts to media download notifications

🔧 Setting Up ntfy with Docker

Here's how I spin up ntfy on my server:

  ntfy:
    image: binwiederhier/ntfy
    container_name: ntfy
    restart: unless-stopped
    command:
      - serve
    environment:
      - TZ=${TIME_ZONE}
    user: 1000:1000
    volumes:
      - ${VOLUMES_DIR}/ntfy/cache:/var/cache/ntfy
      - ${VOLUMES_DIR}/ntfy/config:/etc/ntfy

Key Volumes:

  • ${VOLUMES_DIR}/ntfy/cache: persists messages
  • ${VOLUMES_DIR}/ntfy/config: holds your ntfy.yml config for access control or auth if needed

Optionally, I run it behind a reverse proxy like Traefik with HTTPS, so I can access it on https://ntfy.mydomain.com.

💡 Why Self-Host ntfy?

  • Privacy: Notifications don’t touch a third-party server
  • Reliability: No cloud outages, no rate limits
  • Flexibility: I can plug it into any script or app using curl
  • No Vendor Lock-in: Push to any topic using HTTP, MQTT, or the ntfy app

🔔 Real-World Uses

1. ✅ Backup Job Completion

I have automated backups running via rsync and rclone. Once they finish, I send myself a push notification:

I run my backup script with an alias which calls a ntfy function I created in bash.

alias backup='mac_backup && ntfy "Mac Backup" "Backup Successful" "100" || ntfy "Mac Backup" "Backup Failed" "hankey"'

Now I don’t have to sit and watch it run — my phone tells me right away.

2. 📜 Bash Script Alerts

I have automated tasks that run in my home and work environment. Simple admin tasks I may have automated with bash or python scripts now notify me on completion.

3. 💽 Low Disk Space Warnings

A cron job runs every day and checks disk space on my home server:

#At 8am check free disk space, if under 10 gig send ntfy to alert
0 8 * * * ~/scripts/low-disk-space-alert.sh >/dev/null 2>&1

This is my script that runs to notify my if my homelab server disk free space goes below 10 Gb

#!/bin/bash

mingigs=10
avail=$(df | awk '$6 == "/" && $4 < '$mingigs' * 1024*1024 { print $4/1024/1024 }')
topicurl=https://mydomain.com/topic

if [ -n "$avail" ]; then
  curl \
    -d "Only $avail GB available on the root disk. Better clean that up." \
    -H "Authorization: Bearer tk_1234561234556" \
    -H "Title: Low disk space alert on $(hostname)" \
    -H "Priority: high" \
    -H "Tags: warning,cd" \
    $topicurl
fi

4. 🎬 Media Downloads Ready

Ntfy integrates directly into most home media systems, such as Sonarr, Radarr, qBittorrent etc.

I can even send rich messages with priority, attachments, or actions if needed.

5. 🔐 SSH Login Notification

Using PAM hooks, I get notified on every SSH login to my server:

Just add this to /etc/pam.d/sshd

# Notify when ssh access to this server
session optional pam_exec.so /usr/bin/ntfy-ssh-login.sh

If there is any ssh access to my home lab server this the following script runs notifying me of the access

#!/bin/bash

topicurl=https://mydomain.com/topic

if [ "${PAM_TYPE}" = "open_session" ]; then
      curl \
      -H "Authorization: Bearer tk_1234561234556" \
      -H "Priority: high" \
      -H "Title: Server Accessed" \
      -H "Tags: warning" \
      -d "SSH login: ${PAM_USER} from ${PAM_RHOST}" \
      $topicurl
fi

📲 Mobile Notifications

The ntfy Android app (or iOS app) pairs beautifully with this. Just subscribe to the relevant topics, and you’ll get instant push notifications — with no Google Firebase required if you enable polling.

🔚 Final Thoughts

Self-hosting a notification service like ntfy has been one of the most useful additions to my infrastructure. It's minimal, fast, and integrates into literally anything that can run a curl command.

From backups to logins to disk health and even service uptime monitoring of my home lab — it keeps me informed, in real-time, without relying on external services.