You ran docker run -p 3001:3001 louislam/uptime-kuma, added a few HTTP monitors, the green ticks looked reassuring, you walked away. Six months later port 3001 is on the public NAT, the SQLite database lives inside the container (so the upgrade you did three months ago lost the monitor history), the status page is unreachable from outside because the only URL anybody has is http://1.2.3.4:3001, and the push monitor on the nightly batch job has been silently failing for weeks because nobody ever finished wiring it.
What’s happening
Uptime Kuma is a single Node app with a SQLite database, and the failure mode is always the same: data lives on a named Docker volume that nobody named, the container is exposed directly to the internet, and the upgrade path mutates the schema in place. To keep it production-ready, the data volume needs a real mount path you can back up; the container port belongs on 127.0.0.1; nginx with a TLS cert handles the public side; the status page slug needs a sensible default (otherwise the only way in is to know the admin URL); and push monitors — which are the only way to alert on cron-style “this job should have happened” failures — need their token saved somewhere durable. None of this is exotic. The trap is treating Kuma like a desktop tool.
How to verify
After install, the listener should bind to localhost only (nginx is the public side):
ss -lntp | grep -E ':(3001|443|80)\b'
# 127.0.0.1:3001 docker-proxy -> uptime-kuma
# 0.0.0.0:443 nginx
# 0.0.0.0:80 nginx
The container should be healthy under its compose project:
docker compose -f /opt/uptime-kuma/docker-compose.yml ps
The data volume must be a real mount on the host, not an anonymous Docker volume:
docker inspect uptime-kuma --format '{{ range .Mounts }}{{ .Type }} {{ .Source }} -> {{ .Destination }}{{ "\n" }}{{ end }}'
# bind /opt/uptime-kuma/data -> /app/data
If that line shows volume instead of bind, the upgrade path will surprise you.
The fix
Save the script below as /root/setup-uptime-kuma-ubuntu2204.sh, then run it. It performs the full installer flow on a fresh Ubuntu 22.04 VM: base update, UFW, SSH hardening (root key login kept, password disabled), unattended-upgrades for security, Docker engine + compose plugin from the upstream Docker repo, a pinned louislam/uptime-kuma 1.x image, a Compose stack with a real bind mount at /opt/uptime-kuma/data, the container bound to 127.0.0.1:3001, nginx + certbot for the public TLS front, and LimitNOFILE=64000 on the Docker daemon. The script waits for the app to become reachable before continuing.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 Uptime Kuma clean VM installer
### Pins louislam/uptime-kuma to a 1.x tag
### Container bound to 127.0.0.1:3001; only nginx is public
### Data persisted as bind mount at /opt/uptime-kuma/data
### TLS via Let's Encrypt
### Keeps root SSH key login; disables password auth
### No local backups; assumes VM-level backup
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${KUMA_DOMAIN:?Set KUMA_DOMAIN, e.g. status-admin.example.com}"
: "${KUMA_EMAIL:?Set KUMA_EMAIL for Let's Encrypt}"
KUMA_VERSION="${KUMA_VERSION:-1.23.13}"
echo
echo "========================================"
echo "Uptime Kuma Ubuntu 22.04 Setup"
echo "Domain: $KUMA_DOMAIN"
echo "Version: $KUMA_VERSION"
echo "========================================"
echo
export DEBIAN_FRONTEND=noninteractive
echo "==> Updating base OS"
apt-get update
apt-get -y upgrade
echo "==> Installing base packages"
apt-get -y install \
curl wget ca-certificates gnupg \
chrony fail2ban unattended-upgrades \
lsof tcpdump dnsutils iproute2 net-tools jq \
nginx \
ufw
systemctl enable --now chronyd 2>/dev/null || systemctl enable --now chrony
echo "==> sysctl + file limits"
cat > /etc/sysctl.d/99-kuma.conf <<'SYSCTL'
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
fs.file-max = 2097152
kernel.dmesg_restrict = 1
SYSCTL
sysctl --system
cat > /etc/security/limits.d/99-kuma.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
LIMITS
echo "==> Hardening SSH (keep root key)"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
set_sshd() {
local k="$1" v="$2"
if grep -qE "^[#[:space:]]*${k}[[:space:]]+" /etc/ssh/sshd_config; then
sed -i "s|^[#[:space:]]*${k}[[:space:]].*|${k} ${v}|" /etc/ssh/sshd_config
else
echo "${k} ${v}" >> /etc/ssh/sshd_config
fi
}
set_sshd PermitRootLogin prohibit-password
set_sshd PasswordAuthentication no
set_sshd PubkeyAuthentication yes
set_sshd KbdInteractiveAuthentication no
set_sshd X11Forwarding no
set_sshd ClientAliveInterval 300
set_sshd MaxAuthTries 4
sshd -t
systemctl restart ssh
echo "==> fail2ban + unattended-upgrades"
cat > /etc/fail2ban/jail.d/sshd.local <<'F2B'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
F2B
systemctl enable --now fail2ban
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'AUTO'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
AUTO
systemctl enable --now unattended-upgrades
echo "==> UFW: 22, 80, 443 only"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
echo "==> Installing Docker engine + compose plugin"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" \
> /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/limits.conf <<'DLIM'
[Service]
LimitNOFILE=64000
DLIM
systemctl daemon-reload
systemctl enable --now docker
echo "==> Preparing Uptime Kuma project"
mkdir -p /opt/uptime-kuma/data
chown root:root /opt/uptime-kuma /opt/uptime-kuma/data
cat > /opt/uptime-kuma/docker-compose.yml <<COMPOSE
services:
uptime-kuma:
image: louislam/uptime-kuma:${KUMA_VERSION}
container_name: uptime-kuma
restart: unless-stopped
ports:
- "127.0.0.1:3001:3001"
volumes:
- /opt/uptime-kuma/data:/app/data
healthcheck:
test: ["CMD", "extra/healthcheck"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
ulimits:
nofile:
soft: 64000
hard: 64000
environment:
UPTIME_KUMA_DISABLE_FRAME_SAMEORIGIN: "0"
TZ: "America/Toronto"
COMPOSE
echo "==> Starting Uptime Kuma"
cd /opt/uptime-kuma
docker compose pull
docker compose up -d
echo "==> Waiting for app on 127.0.0.1:3001"
for i in {1..60}; do
if curl -fsS http://127.0.0.1:3001/ -o /dev/null 2>&1; then
echo " kuma up"
break
fi
sleep 2
done
echo "==> nginx + Let's Encrypt"
apt-get -y install certbot python3-certbot-nginx
cat > /etc/nginx/sites-available/uptime-kuma <<NGINX_BOOT
server {
listen 80;
server_name ${KUMA_DOMAIN};
location /.well-known/acme-challenge/ { root /var/www/html; }
location / { return 200 'bootstrap'; }
}
NGINX_BOOT
ln -sf /etc/nginx/sites-available/uptime-kuma /etc/nginx/sites-enabled/uptime-kuma
rm -f /etc/nginx/sites-enabled/default
mkdir -p /var/www/html
nginx -t && systemctl reload nginx
if [[ ! -d /etc/letsencrypt/live/${KUMA_DOMAIN} ]]; then
certbot certonly --webroot -w /var/www/html \
-d "${KUMA_DOMAIN}" -m "${KUMA_EMAIL}" --agree-tos --non-interactive
fi
cat > /etc/nginx/sites-available/uptime-kuma <<NGINX
server {
listen 80;
server_name ${KUMA_DOMAIN};
location /.well-known/acme-challenge/ { root /var/www/html; }
location / { return 301 https://\$host\$request_uri; }
}
server {
listen 443 ssl http2;
server_name ${KUMA_DOMAIN};
ssl_certificate /etc/letsencrypt/live/${KUMA_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${KUMA_DOMAIN}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
add_header Strict-Transport-Security "max-age=31536000" always;
location / {
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 90s;
proxy_send_timeout 90s;
}
}
NGINX
nginx -t && systemctl reload nginx
systemctl enable --now certbot.timer 2>/dev/null || true
echo "==> Final apt upgrade"
apt-get -y upgrade
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(3001|443|80)\b' || true
echo
echo "Container:"
docker compose -f /opt/uptime-kuma/docker-compose.yml ps
echo
echo "Mount sanity check:"
docker inspect uptime-kuma --format '{{ range .Mounts }}{{ .Type }} {{ .Source }} -> {{ .Destination }}{{ "\n" }}{{ end }}'
echo
echo "Public URL: https://${KUMA_DOMAIN}/"
echo
echo "Next steps in the UI:"
echo " 1) Create the admin account on first visit"
echo " 2) Add HTTP monitors (Type: HTTP(s))"
echo " 3) For cron-style 'job should have happened' alerts:"
echo " New Monitor -> Type: Push -> save the URL it gives you"
echo " In your cron tail: curl -fsS \"<push-url>\" || true"
echo " 4) Create a Status Page, set slug like 'public', map monitors to groups"
echo " It will live at https://${KUMA_DOMAIN}/status/public"
echo " 5) Save the data backup target: /opt/uptime-kuma/data (SQLite + uploads)"
Make it executable and run it:
chmod 700 /root/setup-uptime-kuma-ubuntu2204.sh
KUMA_DOMAIN=status-admin.example.com KUMA_EMAIL=ops@example.com \
/root/setup-uptime-kuma-ubuntu2204.sh
The script prints the listener state, the container health, the mount mapping, and the URL. The first visit walks you through admin creation. Two things to wire on day one: push monitors for any cron-style job where silence is the failure (give the cron the push URL with || true so the job exit code doesn’t change), and a status page on a sensible slug — Kuma’s public page lives at /status/<slug>, so a slug like public gives https://status-admin.example.com/status/public. If the public status page should live on a different domain, point that domain at this VM and add a second nginx server block targeting the same upstream.
Stack Harbor wires Uptime Kuma into the managed on-call rotation as part of environment management — push monitors covering nightly jobs and status pages reviewed in our Monitoring & Support practice. Get a status-page review.