Skip to content

ntfy

ntfy lets you send push notifications to your phone or desktop via scripts from any computer, using simple HTTP PUT or POST requests.

References


Make directory

Terminal window
mkdir -p {{DOCKER_PATH_VAR}}/ntfy && cd {{DOCKER_PATH_VAR}}/ntfy

compose.yml

Terminal window
nano compose.yml
compose.yml
services:
ntfy:
image: binwiederhier/ntfy
container_name: ntfy
command:
- serve
environment:
- TZ=UTC
volumes:
- ./cache:/var/cache/ntfy
- ./config:/etc/ntfy
- ./auth:/var/lib/ntfy
ports:
- 8383:80
healthcheck:
test: ["CMD-SHELL", "wget -q --tries=1 http://localhost:80/v1/health -O - | grep -Eo '\"healthy\"\\s*:\\s*true' || exit 1"]
interval: 60s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
init: true

./config/server.yml

Terminal window
nano ./config/server.yml
./config/server.yml
# Base configuration
base-url: "http://localhost:8383"
listen-http: ":80"
# Auth settings
auth-file: "/var/lib/ntfy/user.db"
auth-default-access: "deny-all"
# Cache settings
cache-file: "/var/cache/ntfy/cache.db"
cache-duration: "12h"

Start container

Terminal window
docker compose up -d

Create admin user

Terminal window
docker exec -it ntfy ntfy user add --role=admin {{USERNAME_VAR}}

Create token

Terminal window
docker exec -it ntfy ntfy token add {{USERNAME_VAR}}

Example usage

HTTP

Terminal window
curl -X POST "http://localhost:8383/test_topic" \
-H "Authorization: Bearer <tk_your_token>" \
-H "Title: Test Title" \
-H "Tags: rocket,star" \
-H "Priority: default" \
-d "Message using a token"

CLI

Requires CLI to be installed through your package manager.

Terminal window
ntfy publish \
--host="http://localhost:8383" \
--token="<tk_your_token>" \
--title="Test Title" \
--tags="rocket,star" \
--priority="default" \
test_topic "Message using a token"

Open web ui

http://localhost:8383/test_topic or http://{{SERVER_IP_VAR}}:8383/test_topic