• About PinoyLinux
    • PinoyLinux.org
    • Documentation
    • Support
    • Feedback
Skip to content
PinoyLinux
Menu
  • HOME
  • EBOOKS
  • TOPICS+
    • Artificial Intelligence
    • Containers
    • Desktop
    • DevOps
    • Linux Kernel
    • Mobile
    • Network Administration
    • Programing
    • Privacy and Security
    • Servers
    • Storage
    • System Adminstration
Menu
self host NTFY

Installing Self Host NTFY On Linux Using Docker Container

Posted on September 10, 2023

The NTFY generally stands for “Notify”, a 100% free or opensource and created by Phillipp Heckel. REST-API-based publish-subscribe notification service (using simple HTTP PUT or POST requests) ; a utility that lets you send push notifications to your mobile phone or desktop via scripts from any computer.

It supports shell integration with popular Linux shells such as bash and zsh; It also offers features for process, emjoi, XMPP, Telegram, Instapush and Slack notification support.

Lets assumed that you have already installed and running Docker service in your system.

Install NTFY

● Host network
Executing the command line below will create a container for ntfy that uses host network:

docker run -d --name=ntfy --restart=always --network=host \
-v /opt/ntfy/cache:/var/cache/ntfy \
binwiederhier/ntfy serve --cache-file /var/cache/ntfy/cache.db

● User-defined bridge network
User-defined bridge network can be used for listening on different port using -p option

docker network create app-net
docker run -d --name=ntfy --restart=always --network=app-net \
-p 8089:80 \
-v /opt/ntfy/cache:/var/cache/ntfy \
binwiederhier/ntfy serve --cache-file /var/cache/ntfy/cache.db

● Using docker-compose with non-root user and healthchecks enabled:

version: "2.3"
services:
ntfy:
image: binwiederhier/ntfy
container_name: ntfy
command:
- serve
environment:
- TZ=UTC # optional: set desired timezone
user: UID:GID # optional: replace with your own user/group or uid/gid
volumes:
- /var/cache/ntfy:/var/cache/ntfy
- /etc/ntfy:/etc/ntfy
ports:
- 8089:80
healthcheck: # optional: remember to adapt the host:port to your environment
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

If using a non-root user when running the docker version, be sure to chown the server.yml, user.db, and cache.db files and attachments directory to the same uid/gid.

Alternatively, you may wish to build a customized Docker image that can be run with fewer command-line arguments and without delivering the configuration file separately.

FROM binwiederhier/ntfy
COPY server.yml /etc/ntfy/server.yml
ENTRYPOINT ["ntfy", "serve"]


Accessing And Testing NTFY

To access web UI, open a web browser and go to http://<HOST_IP_ADDRESS>:<PORT>

access-ntfy
access ntfy
config-ntfy
config ntfy
access-subscribed
access subscribed

Once you have accessed the url and done the basic configuration based on the sample screenshot above, you may now publish topic or test message notification using sample scripts below (curl and php).

Example1: Command line (curl)

curl \
-d "HELLOWORLD PINOYLINUX.ORG" \
https://localhost:8089/RockITPinoyNotifications

Example2: PHP

file_get_contents('https://localhost:8089/RockITPinoyNotifications', false, stream_context_create([
'http' => [
'method' => 'POST', // PUT also works
'header' =>
'Content-Type: text/plain\r\n' .
'content' => 'HELLOWORLD PINOYLINUX.ORG'
]
]));

Example3: RSYNC

rsync -rvapl --numeric-ids --progress admin@pinoylinux.org/home/admin/* . \
&& zfs snapshot ... \
&& curl -H prio:low -d "Server backup succeeded" ntfy.sh/adminfolderbackups \
|| curl -H tags:warning -H prio:high -d "Server backup failed" ntfy.sh/adminfolderbackups

 

Uninstall NTFY
To completely remove ntfy, remove its container:

docker rm --force ntfy

Remove ntfy image:

docker rmi binwiederhier/ntfy

You can also remove ntfy data:

sudo rm -rf /opt/ntfy

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Reference:

https://ntfy.sh/
https://www.docker.com/

Author Profile

rockitpinoy
rockitpinoy
Latest entries
  • git-commandsDevOpsSeptember 19, 2023Basic Git Commands For Gitlab Developers
  • Deploy-OpenVZ-7 +-ContainersContainersSeptember 18, 2023Deploy OpenVZ 7 Containers
  • self host NTFYContainersSeptember 10, 2023Installing Self Host NTFY On Linux Using Docker Container
  • free-ssl-on-apache2-v2Privacy and SecurityAugust 24, 2023How To Install FREE SSL (Let’s Encrypt) With Apache2.4 On CentOS7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Breaking News

  • New 'Mirrored' Network Mode Introduced in Windows Subsystem for Linux
  • Linux Threat Report: Earth Lusca Deploys Novel SprySOCKS Backdoor in Attacks on Government Entities
  • Linux Kernel Faces Reduction in Long-Term Support Due to Maintenance Challenges
  • Linux Celebrates 32 Years with the Release of 6.6-rc2 Version
  • Introducing Bavarder: A User-Friendly Linux Desktop App for Quick ChatGPT Interaction

Site Stats

  • 0
  • 2
  • 33
  • 213
  • 19,506
©2023 PinoyLinux | All Rights Reserved
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}