2026-12-03 · gotify · docker · self-hosting · push-notifications
Self-Host Gotify with Docker: Push Notifications on Your VPS
Run Gotify in Docker Compose behind Caddy: SQLite data volume, TZ and GOTIFY_DEFAULTUSER_PASS env vars, WebSocket-ready reverse proxy, backups.
- Total RAM
- 9.9 MB
- Startup
- 52.2 s
- Port
- 8080
- HTTP
- 200
What Gotify does and what it needs
Gotify is a small Go server that pushes messages to clients in real time over WebSocket. You POST to its REST API, and any subscribed client (web UI, Android app, gotify/cli) receives the message instantly. It manages users, applications, and clients from a built-in web UI, and supports plugins.
Under the hood it’s a single binary. By default it stores everything in a SQLite database under /app/data, alongside uploaded application images and any Let’s Encrypt certificates if you enable that feature. That directory is the only state you need to persist. The upstream project does not publish a minimum memory figure; a small VPS handles idle traffic easily, and memory grows with the number of connected WebSocket clients and message throughput.
The container listens on port 80 internally. The official docs show -p 80:80, but on a VPS you almost always want a reverse proxy in front, so we bind to 127.0.0.1:8080 and let Caddy terminate TLS.
Prerequisites, ports, and volume constraints
- A Linux host with Docker Engine 24+ and the Compose plugin (
docker compose version). - A DNS A/AAAA record pointing at the VPS if you want HTTPS. For local testing you can skip the domain and use an SSH tunnel.
- Port
8080on localhost (the container’s internal port 80 is mapped here). Caddy will listen on80and443. - One named volume,
gotify_data, mounted at/app/data. Back this up; it holds the SQLite DB and uploads. - The container runs as UID
1234by default. If you switch to a bind mount instead of a named volume,chown -R 1234:1234the host directory first, otherwise Gotify can’t write the DB. - Time zone is set via
TZ; the docs call this out explicitly because message timestamps and logs use it.
Production Docker Compose setup
Create the project directory and files:
mkdir -p ~/gotify && cd ~/gotify
Generate a strong admin password and write the .env file:
cat <<EOF > .env
GOTIFY_DEFAULTUSER_PASS=$(openssl rand -hex 24)
TZ=UTC
EOF
chmod 600 .env
GOTIFY_DEFAULTUSER_PASS is only read on first boot to create the admin user. After that, change the password from the UI and you can drop the variable. Keep the .env file around until you’ve logged in once.
Now the compose file:
cat <<'EOF' > compose.yml
services:
gotify:
image: gotify/server:latest
container_name: gotify
restart: unless-stopped
ports:
- "127.0.0.1:8080:80"
environment:
TZ: ${TZ:-UTC}
GOTIFY_DEFAULTUSER_PASS: ${GOTIFY_DEFAULTUSER_PASS}
volumes:
- gotify_data:/app/data
volumes:
gotify_data:
EOF
Start it:
docker compose up -d
docker compose logs -f gotify
You should see Gotify log that it’s listening on :80. The web UI is now reachable at http://127.0.0.1:8080 from the host only. To test from your laptop without a domain, tunnel it:
ssh -L 8080:127.0.0.1:8080 user@your-vps
Then open http://localhost:8080 and log in as admin with the password from .env.
Reverse proxy, HTTPS, and first-run hardening
Gotify needs two things from the proxy: WebSocket upgrade support (the UI and clients hold a long-lived connection to /stream) and correct X-Forwarded-* headers so links and redirects use your public hostname. No upload size limit is required by default, but if you plan to POST large messages, raise the body limit to a few MB.
Install Caddy on the host (not in Compose) and point it at the loopback port:
gotify.example.com {
encode zstd gzip
request_body {
max_size 10MB
}
reverse_proxy 127.0.0.1:8080 {
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
}
}
Caddy handles WebSocket upgrades automatically and provisions a Let’s Encrypt certificate for the hostname. Reload with sudo systemctl reload caddy.
First-run hardening checklist:
- Log in as
adminimmediately after the first boot and change the password. The default is whatever you put in.env; anyone who reads that file before you rotate it owns your instance. - Remove
GOTIFY_DEFAULTUSER_PASSfrom.envand rundocker compose up -dagain so the secret isn’t sitting on disk. - Create a dedicated application per sender (e.g.
backups,monitoring) instead of reusing one token everywhere. Each app has its own token you can revoke independently. - If you don’t need public sign-ups, keep the default single-user setup and create additional users manually from the UI. Gotify doesn’t expose an open registration endpoint, but don’t hand out the admin account.
- Restrict the API to the proxy if you can: since the container only binds to
127.0.0.1, the only public entry point is Caddy, which is what you want.
Updating, backups, and common pitfalls
Update:
cd ~/gotify
docker compose pull
docker compose up -d
docker compose logs --tail=50 gotify
Gotify runs its own migrations on startup against the SQLite DB. Pull a backup before every upgrade in case a migration goes sideways.
Backup the gotify_data volume:
docker run --rm \
-v gotify_gotify_data:/data \
-v "$PWD":/backup \
alpine tar czf /backup/gotify-$(date +%F).tar.gz -C /data .
The volume name is prefixed with the Compose project name (the directory name by default), so gotify_gotify_data matches ~/gotify. Verify with docker volume ls if you renamed the folder. Restore by stopping the container, extracting the tarball back into the volume, and starting it again.
Two pitfalls worth knowing:
- Permissions on bind mounts. If you replace the named volume with
./gotify_data:/app/data, the container’s UID1234must own the directory. The docs explicitly call outsudo chown -R 1234:1234 ./gotify_data. Skip it and Gotify fails to create the SQLite file with a permission error. - WebSocket through the proxy. A proxy that buffers responses or strips
Upgrade/Connectionheaders will break the live stream: the UI loads but messages never arrive. Caddy and Nginx both work if you enable upgrade handling; test by sending a message withcurl -X POST 'https://gotify.example.com/message?token=<app-token>' -F 'title=test' -F 'message=hello'and watching the UI.
Also remember TZ: if it’s unset, timestamps in the UI and logs default to UTC, which makes correlating alerts with local events annoying. Set it once in .env and leave it.
Measured in our sandbox run: total memory 9.9 MB (sum of per-container peaks over a 30s idle window after startup) across 1 container; largest container 9.9 MB; published port(s) 8080; HTTP probe returned 200. The run took 52.2s including the image download. Required secret(s) GOTIFY_DEFAULTUSER_PASS were generated for the test run, as the tutorial instructs.
Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.