What is Uptime Kuma?

Uptime Kuma is a self-hosted monitoring tool that actively tracks the availability and status of your services, providing instant alerts if something goes down. It can be used to monitor network hardware, servers, databases, open ports, system services, Docker containers, web applications, and SSL/TLS certificate expiration dates. When an outage or issue is detected, Uptime Kuma can immediately send alerts through integrated messaging applications, mobile push notification services, dedicated IT alerting platforms, or email.

Installation

This guide assumes that both Docker and Portainer are already installed.

Access Portainer's web GUI in your browser.

Under your Docker environment menu, select Stacks.

Click on + Add stack.

Give your stack a name.

In the Web editor, paste the below text:

services:
    uptime-kuma:
        image: louislam/uptime-kuma:1
        container_name: uptime-kuma

    restart: unless-stopped

    security_opt:
        - no-new-privileges:true

    ports:
        - 3001:3001

    volumes:
        - uptime-kuma:/app/data

volumes:
    uptime-kuma:

Ensure Access control is enabled and set to Administrators.

Click on Deploy the stack.

In your web browser, access the Uptime Kuma web GUI. Replace server-ip with your server IP address:

http://server-ip:3001

You will be prompted to create an administrator account. Do not use Admin or Administrator as the username.

Confirm that the Docker environment starts on boot:

Terminal
sudo reboot

After the reboot completes:

Terminal
docker ps

Hardening

There are some small changes you want to make in order to set a strong baseline security configuration.

Make an Uptime Kuma directory:

Terminal
mkdir -p ~/docker/uptime-kuma

Restrict access to your local subnet(s). Substitute your local subnet in the command below:

Terminal
sudo ufw allow from 10.0.0.0/24 to any port 3001 proto tcp

Create an update automation script:

Terminal
sudo nano /usr/local/bin/uptime-kuma-updates.sh

Add the below text, replacing user-name with the appropriate value:

#!/bin/bash

docker pull louislam/uptime-kuma:1

docker stop uptime-kuma
docker rm uptime-kuma

docker run -d \
    --name uptime-kuma \
    --restart unless-stopped \
    --security-opt no-new-privileges:true \
    -p 3001:3001 \
    -v uptime-kuma:/app/data \
    louislam/uptime-kuma:1

docker image prune -f

Press CTRL+O to save the file, then press CTRL+X to close.

Make the script executable:

Terminal
sudo chmod +x /usr/local/bin/uptime-kuma-updates.sh

Test the script:

Terminal
sudo /usr/local/bin/uptime-kuma-updates.sh

Schedule the script to run daily by adding a cron job:

Terminal
sudo crontab -e

Add the following lines:

# Uptime Kuma Updates
45 3 * * * /usr/local/bin/uptime-kuma-updates.sh >> /var/log/uptime-kuma-updates.log 2>&1

The update log can be checked by running the command:

Terminal
sudo cat /var/log/uptime-kuma-updates.log

Loading...