This tutorial installs Umami 3.5.1, an open source alternative to Google Analytics, on an Ubuntu 24.04 VPS with Docker Compose. The data lives in a PostgreSQL 18.7 database that only Umami can reach, and the dashboard sits behind Caddy 2.11.9 with automatic HTTPS. By the end, the tracking script is on your site, a click is counted as an event, and the database backup and restore are tested. Everything was tested on December 6, 2026 in a clean Ubuntu 24.04.5 LTS container (amd64).
On this page
- Versions used
- What you need
- 1. Create the folder and the .env file
- 2. Create the Caddyfile and docker-compose.yml
- 3. Validate and start
- 4. Change the admin password
- 5. Add the site and install the tracking script
- 6. Back up and restore the database
- 7. Update Umami
- Common problems
- What the test did not cover
- Next steps

Versions used
| Component | Version | Source |
|---|---|---|
| Umami | 3.5.1 (2026-12-02) |
Umami releases |
| PostgreSQL | 18.7-alpine |
Docker Hub |
| Caddy | 2.11.9 (2026-11-05) |
Caddy releases |
| Docker Engine | 29.10.1 |
official apt repository |
| Docker Compose | v5.8.1 (plugin) |
official apt repository |
| System | Ubuntu 24.04.5 LTS, amd64 |
The tags are pinned in the Compose file. The docker-compose.yml in the Umami repository uses umami:latest and postgres:15-alpine. Here both images have a fixed version, and every version change is a step you decide on, with a backup first.
What you need
- A VPS with 64-bit Ubuntu 24.04 and a user with
sudo(the examples usedeploy). If the machine is brand new, start with First security steps on an Ubuntu 24.04 VPS. - Docker and the Compose plugin installed from the official repository, as in How to install Docker and Docker Compose on Ubuntu 24.04.
- A subdomain with a DNS
Arecord pointing to the VPS IPv4 address. The examples useanalytics.example.com. - Ports
80and443free and open in the firewall, so Caddy can issue and renew the Let's Encrypt certificate. Umami's port3000and PostgreSQL's5432stay out ofports:, because Docker publishes ports aroundufw(see The Docker port is still open with ufw).
With the dashboard open, one site registered and a few events, the test measured about 206 MiB of RAM for Umami, 85 MiB for PostgreSQL and 52 MiB for Caddy. The Umami image takes 1.37 GB of disk once pulled. The stack fits easily on any Docker VPS plan.
1. Create the folder and the .env file
Create the project folder:
mkdir -p ~/umami && cd ~/umamiGenerate the .env file with the domain and three random secrets. Replace analytics.example.com with your subdomain:
cat > .env <<EOF
UMAMI_DOMAIN=analytics.example.com
POSTGRES_PASSWORD=$(openssl rand -hex 24)
APP_SECRET=$(openssl rand -hex 32)
TWO_FACTOR_ENCRYPTION_KEY=$(openssl rand -hex 32)
EOF
chmod 600 .envPOSTGRES_PASSWORDis the database password. It goes into Umami'sDATABASE_URL, which is why the value is hexadecimal: only letters and digits, nothing that needs escaping in a URL.APP_SECRETsigns logins and is part of how anonymous session IDs are computed. It has been required since 3.5.0, and Umami rejects an empty value or the placeholder. Changing it later signs everyone out and makes returning visitors count as new.TWO_FACTOR_ENCRYPTION_KEYencrypts the two-factor authentication secrets. Without it, no user can turn on 2FA.
All three are described on the Umami environment variables page.
2. Create the Caddyfile and docker-compose.yml
Create the Caddyfile. Caddy requests the Let's Encrypt certificate, redirects HTTP to HTTPS and compresses responses:
{$UMAMI_DOMAIN} {
encode zstd gzip
reverse_proxy umami:3000
}Create docker-compose.yml. Only caddy declares ports:. PostgreSQL sits on a backend network marked internal, which only Umami can reach:
name: umami
services:
db:
image: postgres:18.7-alpine
restart: unless-stopped
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
volumes:
- umami_db:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U umami -d umami"]
interval: 5s
timeout: 5s
retries: 10
networks:
- backend
umami:
image: ghcr.io/umami-software/umami:3.5.1
restart: unless-stopped
init: true
environment:
DATABASE_URL: postgresql://umami:${POSTGRES_PASSWORD}@db:5432/umami
APP_SECRET: ${APP_SECRET:?set APP_SECRET in .env}
TWO_FACTOR_ENCRYPTION_KEY: ${TWO_FACTOR_ENCRYPTION_KEY:?set TWO_FACTOR_ENCRYPTION_KEY in .env}
DISABLE_TELEMETRY: "1"
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/heartbeat || exit 1"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- backend
- proxy
caddy:
image: caddy:2.11.9
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
environment:
UMAMI_DOMAIN: ${UMAMI_DOMAIN:?set UMAMI_DOMAIN in .env}
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
umami:
condition: service_healthy
networks:
- proxy
networks:
backend:
internal: true
proxy:
volumes:
umami_db:
caddy_data:
caddy_config:DISABLE_TELEMETRY turns off the anonymous telemetry Umami sends. The healthcheck uses the /api/heartbeat route, and Caddy only starts after Umami answers. That way it does not return 502 while Umami is still applying migrations.
3. Validate and start
Validate both files before starting:
cd ~/umami
docker compose config -q && echo CONFIG_OK
docker run --rm --env-file .env -v "$PWD/Caddyfile:/etc/caddy/Caddyfile:ro" caddy:2.11.9 caddy validate --config /etc/caddy/CaddyfileThe first command prints CONFIG_OK, and the second ends with Valid configuration. Start the stack:
docker compose up -d
docker compose psIn the test, with the images already pulled, up -d took about 30 seconds, because Caddy waits for Umami to become healthy. docker compose ps showed db and umami as (healthy), umami with only 3000/tcp (an internal port, not mapped to the host) and caddy with 0.0.0.0:80->80/tcp and 0.0.0.0:443->443/tcp.
On the first start, Umami creates its tables. Check the end of the log:
docker compose logs umami | tail -n 6All migrations have been successfully applied.
✓ Database is up to date.
▲ Next.js 16.4.6
- Local: http://localhost:3000
- Network: http://0.0.0.0:3000Check that only Caddy's ports are listening on the host:
sudo ss -tulpn | grep -E ':(80|443|3000|5432)\b'Only docker-proxy shows up, on ports 80 and 443. Test the redirect and the health route:
curl -sSI http://analytics.example.com/ | head -n 3
curl -fsS https://analytics.example.com/api/heartbeatThe expected answers are HTTP/1.1 308 Permanent Redirect, with Location: https://analytics.example.com/, and {"ok":true}. If HTTPS fails or returns 502, Fix Caddy 502 Bad Gateway and HTTPS errors with Docker covers DNS, ports and service names.
4. Change the admin password
Umami starts with the user admin and the password umami. As long as that password works, anyone who opens the subdomain gets into the dashboard. Do this right after up -d:
- Open
https://analytics.example.comand sign in withadminandumami. - Click the
adminuser, open Settings and go to Security. - Click Change password, enter the current password (
umami) and a strong one, stored in a password manager.
In the test, after the change, signing in with admin and umami returned 401. On the same screen, Enable 2FA turns on two-factor authentication, which works because .env already has TWO_FACTOR_ENCRYPTION_KEY.
5. Add the site and install the tracking script
In the top menu, open Websites and click Add website. Enter a name and the site's domain (for example, site.example.com) and save. Open the site from the list, click Edit and copy the code in the Tracking code section. It looks like this, with your site's data-website-id:
<script defer src="https://analytics.example.com/script.js" data-website-id="8e277acc-992b-4805-86e4-15bdc1893989"></script>Paste the line inside the <head> of every page. On a site with templates, it goes in the shared layout; on a static site, in each HTML file. defer keeps the script from delaying page rendering.
To count clicks, add data-umami-event to the element. The value becomes the event name in the dashboard:
<button data-umami-event="cta-contratar">Contratar</button>In the test, the site's page, opened in Chrome with a desktop browser User-Agent, loaded script.js and sent two POST requests to /api/send: a page view on load and an event on the button click. The dashboard then showed 1 visitor and 1 view, as in the image at the top, and the Events tab listed cta-contratar once. The Umami API returned the same counts:
{"pageviews":1,"visitors":1,"visits":1,"bounces":0,"totaltime":3}If your site sets a Content Security Policy, add https://analytics.example.com to script-src, so script.js loads, and to connect-src, for the /api/send calls. Without it, the browser blocks tracking.
6. Back up and restore the database
The database is what needs a backup. Caddy issues certificates again on its own, and Umami keeps no data outside PostgreSQL. pg_dump in custom format runs while the service is up:
mkdir -p ~/backups
cd ~/umami
docker compose exec -T db pg_dump -U umami -d umami --format=custom > ~/backups/umami-$(date +%F).dump
ls -lh ~/backupsTo run it every day at 03:15 and keep 14 days, add this line to the deploy user's crontab -e:
15 3 * * * cd /home/deploy/umami && docker compose exec -T db pg_dump -U umami -d umami --format=custom > /home/deploy/backups/umami-$(date +\%F).dump && find /home/deploy/backups -name 'umami-*.dump' -mtime +14 -deleteIn a crontab, % needs a \ in front, as in date +\%F. Copy the files off the VPS too, because a backup that only lives on the same disk is lost with it. VPS backup with Restic covers copying to S3 storage.
To restore, stop Umami, recreate the database and load the file:
cd ~/umami
docker compose stop umami
docker compose exec -T db psql -U umami -d postgres -c 'DROP DATABASE umami WITH (FORCE);' -c 'CREATE DATABASE umami OWNER umami;'
docker compose exec -T db pg_restore -U umami -d umami --no-owner < ~/backups/umami-YYYY-MM-DD.dump
docker compose start umamiReplace YYYY-MM-DD with the file's date. In the test, the restore brought back the two events recorded before (the page view and the click), and Umami was healthy again in 20 seconds, with the same login.
7. Update Umami
Before each update, read the release notes in the Umami releases and take a backup. Then change the tag in docker-compose.yml and recreate only that service:
cd ~/umami
docker compose exec -T db pg_dump -U umami -d umami --format=custom > ~/backups/umami-before-update.dump
sed -i 's#umami:3.5.1#umami:NEW_VERSION#' docker-compose.yml
docker compose pull umami
docker compose up -d umami
docker compose logs umami | tail -n 5Replace NEW_VERSION with the new version number, without the v of the release tag. Umami applies database migrations on startup. In the test, a fresh 3.5.0 installation updated to 3.5.1 was healthy again in 15 seconds, and the log showed No pending migrations to apply. and ✓ Database is up to date.. Moving PostgreSQL to another major version (from 18 to 19, for example) does not work by changing the tag alone: it requires pg_dump and a restore into a new volume.
Common problems
- The dashboard shows zero visits: open the site in a regular browser without an ad blocker, and check the DevTools Network tab for
script.jsand/api/send. If they are missing, the script is not in the<head>of the published page. If they are blocked, the cause is the CSP or a blocker. - Caddy returns 502 right after
up -d: Umami is nothealthyyet. Checkdocker compose psanddocker compose logs umami. - The database fails with
in 18+, these Docker images are configured...: the volume is mounted at/var/lib/postgresql/data. Use/var/lib/postgresql, as in the Compose file above. - Umami does not start and complains about
APP_SECRET: the variable is empty or still the placeholder. Generate a new one withopenssl rand -hex 32. - Returning visitors counted as new:
APP_SECRETchanged. Restore the value you saved with.env.
What the test did not cover
The test ran in an isolated Ubuntu 24.04.5 LTS container without a public IP, with Docker installed from the official repository and started by hand, because the container has no systemd. DNS propagation, public certificate issuance by Let's Encrypt, ufw and HTTP/3 traffic were left out. Instead of a public certificate, Caddy used tls internal with the same reverse_proxy umami:3000. The test site was a static page served by the same Caddy and opened in Chrome with a desktop browser User-Agent. The memory figures come from that environment and are an order of magnitude.
Next steps
- To get an alert when the site or Umami itself goes down, see How to install Uptime Kuma with Docker Compose and Caddy on a VPS.
- To manage the VPS Docker stacks from a web interface, see How to install Portainer with Docker and Caddy on a VPS.
- To pick the machine, see Docker VPS, Linux VPS and the VPS plans.