Install ntfy Inside Docker Container in Linux

Install ntfy Inside Docker Container in Linux

The ntfy is an HTTP-based publish-subscribe notification service. It can be used to send notifications to a mobile phone or desktop when scripts fail, or long-running terminal commands complete.

This tutorial explains how to install ntfy inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install ntfy

  • Host network

Run the following command to 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. By default, ntfy service is listening on port 80. It can be changed with -p option.

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

Testing ntfy

To access web UI, open a web browser and go to http://<IP_ADDRESS>, where <IP_ADDRESS> is the IP address of the system.

ntfy Inside Docker Container in Linux

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

Leave a Comment

Cancel reply

Your email address will not be published.