2026-12-01 · firefly-iii · finance · docker · self-hosting
Self-Host Firefly III with Docker Compose: Personal Finance Manager
Deploy Firefly III with Docker Compose, MySQL, and Redis for double-entry personal finance. Includes reverse proxy, backups, and hardening.
- Total RAM
- 187.7 MB
- Startup
- 93.6 s
- Port
- 8080
- HTTP
- 302
db 152.0 MB
· app 27.5 MB
· redis 8.2 MB
What Firefly III does and what it needs
Firefly III is a self-hosted personal finance manager built around double-entry bookkeeping. You record transactions between asset, expense, and revenue accounts, then slice the data with budgets, categories, tags, piggy banks, and reports. It ships a REST JSON API, rule-based transaction handling, recurring transactions, and two-factor authentication. Nothing leaves your server unless you explicitly configure an importer or mailer.
The application is a Laravel PHP app. In production it needs a database (MySQL/MariaDB or PostgreSQL; SQLite is supported but not what you want for a multi-year ledger), a persistent storage volume for uploads and attachments, and an APP_KEY that encrypts sensitive columns. Redis is optional but recommended: the env template lets you move CACHE_STORE and SESSION_DRIVER off the filesystem, which keeps the app snappy once you have thousands of transactions.
The upstream project does not publish a minimum memory figure. Practical sizing depends on workload: an idle single-user instance with a few thousand transactions runs comfortably in a small container, while heavy report generation, large CSV imports, and the data importer hammering the API push PHP memory usage up. The env template exposes PHP_MEMORY_LIMIT (default 512M) — raise it if imports or reports get killed.
Prerequisites, ports, and volume constraints
- Docker Engine 24+ with the Compose v2 plugin.
- A hostname pointing at your VPS (e.g.
finance.example.com) if you want HTTPS. You can test on127.0.0.1:8080first. - Port
8080on the host, bound to localhost only. The container listens on8080internally; the official image does not use port 80. - Two named volumes:
firefly_iii_uploadmounted at/var/www/html/storage/upload(attachments, logos, imported files) andfirefly_iii_dbfor MySQL data. Losing the upload volume means losing attachments; losing the DB volume means losing everything. APP_KEYmust be exactly 32 characters. Generate it withopenssl rand -hex 16(32 hex chars) oropenssl rand -base64 32and trim to 32. Changing it later breaks encrypted fields.STATIC_CRON_TOKENis a shared secret used by the built-in cron endpoint. Generate a random string and keep it stable.
Production Docker Compose setup
Create the project directory and the environment file first. Every secret comes from .env; nothing is hardcoded in the compose file.
mkdir -p ~/firefly-iii && cd ~/firefly-iii
cat <<'EOF' > .env
# --- Application ---
APP_ENV=production
APP_DEBUG=false
APP_NAME=FireflyIII
APP_URL=https://${DOMAIN}
APP_KEY=${APP_KEY}
[email protected]
DEFAULT_LANGUAGE=en_US
DEFAULT_LOCALE=equal
TZ=${TZ:-UTC}
TRUSTED_PROXIES=**
LOG_CHANNEL=stack
APP_LOG_LEVEL=notice
AUDIT_LOG_LEVEL=emergency
PHP_MEMORY_LIMIT=512M
# --- Database ---
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=firefly
DB_USERNAME=firefly
DB_PASSWORD=${DB_PASSWORD}
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
# --- Cache / sessions ---
CACHE_STORE=redis
SESSION_DRIVER=redis
REDIS_SCHEME=tcp
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=${REDIS_PASSWORD}
REDIS_DB="0"
REDIS_CACHE_DB="1"
# --- Cookies ---
COOKIE_PATH="/"
COOKIE_DOMAIN=
COOKIE_SECURE=true
COOKIE_SAMESITE=lax
# --- Mail (optional; leave as log until you have SMTP) ---
MAIL_MAILER=log
[email protected]
# --- Cron ---
STATIC_CRON_TOKEN=${STATIC_CRON_TOKEN}
EOF
Now generate the secrets and append them to .env. Do not reuse these values anywhere else.
cat <<EOF >> .env
DOMAIN=finance.example.com
APP_KEY=$(openssl rand -hex 16)
DB_PASSWORD=$(openssl rand -hex 32)
MYSQL_ROOT_PASSWORD=$(openssl rand -hex 32)
REDIS_PASSWORD=$(openssl rand -hex 32)
STATIC_CRON_TOKEN=$(openssl rand -hex 32)
EOF
chmod 600 .env
Write the compose file. The app port is bound to 127.0.0.1 so only the reverse proxy can reach it.
cat <<'EOF' > compose.yml
services:
app:
image: fireflyiii/core:latest
restart: unless-stopped
env_file: .env
environment:
APP_KEY: ${APP_KEY}
DB_CONNECTION: mysql
DB_HOST: db
DB_PORT: "3306"
DB_DATABASE: firefly
DB_USERNAME: firefly
DB_PASSWORD: ${DB_PASSWORD}
REDIS_HOST: redis
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_PASSWORD}
TZ: ${TZ:-UTC}
ports:
- "127.0.0.1:8080:8080"
volumes:
- firefly_iii_upload:/var/www/html/storage/upload
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
db:
image: mariadb:11
restart: unless-stopped
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "no"
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: firefly
MYSQL_USER: firefly
MYSQL_PASSWORD: ${DB_PASSWORD}
TZ: ${TZ:-UTC}
volumes:
- firefly_iii_db:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}", "--appendonly", "yes"]
volumes:
- firefly_iii_redis:/data
volumes:
firefly_iii_upload:
firefly_iii_db:
firefly_iii_redis:
EOF
Start the stack and watch the logs until the app reports it is ready.
docker compose up -d
docker compose logs -f app
On first boot the container runs database migrations automatically. If it exits with a database error, check that DB_PASSWORD in .env matches MYSQL_PASSWORD (both read the same variable, so a mismatch usually means you edited one by hand).
Reverse proxy, HTTPS, and first-run hardening
Firefly III is a Laravel app behind a proxy. Two things matter: the proxy must forward X-Forwarded-Proto and X-Forwarded-For, and TRUSTED_PROXIES must be set so Laravel trusts those headers. The env template explicitly says TRUSTED_PROXIES=** makes reverse proxies work; keep it unless you have a fixed proxy IP.
Set APP_URL to the public HTTPS URL. If you leave it as http://localhost, generated links, password reset emails, and the API base URL will be wrong. COOKIE_SECURE=true requires HTTPS — do not enable it while testing over plain HTTP or you will not be able to log in.
Caddy example (/etc/caddy/Caddyfile):
finance.example.com {
encode gzip
reverse_proxy 127.0.0.1:8080 {
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-For {remote_host}
}
}
Nginx example:
server {
listen 443 ssl http2;
server_name finance.example.com;
client_max_body_size 64m;
location / {
proxy_pass http://127.0.0.1:8080;
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 $scheme;
}
}
client_max_body_size matters: CSV imports and attachment uploads go through the proxy. The default 1 MB will reject them with a 413 before Firefly III ever sees the request.
First-run hardening:
- Visit
https://finance.example.comand register the first user immediately. Firefly III has no separate admin account — the first registered user is the owner. If you expose the instance before registering, anyone can claim it. - Enable two-factor authentication under Options → Profile once you are logged in.
- Keep
APP_DEBUG=false. Debug pages leak environment details. - If you plan to use the data importer, create a dedicated API token under Options → Profile → OAuth instead of reusing your password.
To test without a domain, SSH-tunnel the bound port: ssh -L 8080:127.0.0.1:8080 user@vps and open http://localhost:8080. Set COOKIE_SECURE=false and APP_URL=http://localhost:8080 temporarily, then revert.
Updating, backups, and common pitfalls
Update by pulling the new image and recreating the app container. Migrations run on boot.
cd ~/firefly-iii
docker compose pull app
docker compose up -d app
docker compose logs -f app
Back up both the database and the upload volume. The database dump is the critical piece; the upload volume holds attachments and imported files.
docker compose exec -T db sh -c 'exec mariadb-dump -u root -p"$MYSQL_ROOT_PASSWORD" firefly' > firefly-$(date +%F).sql
docker run --rm -v firefly-iii_firefly_iii_upload:/data -v "$PWD":/backup alpine tar czf /backup/uploads-$(date +%F).tar.gz -C /data .
Restore by piping the SQL back into a fresh db container and extracting the tarball into the upload volume before starting the app.
Two pitfalls worth knowing:
APP_KEYchanges break encrypted data. Firefly III encrypts certain columns withAPP_KEY. If you regenerate it (for example by re-running the secret generation block), existing encrypted fields become unreadable. Back up.envalongside the database.- Cron is required for recurring transactions and reports. The image exposes a cron endpoint guarded by
STATIC_CROON_TOKEN(spelledSTATIC_CRON_TOKENin the env template). If you do not call it on a schedule, recurring transactions will not fire and scheduled reports will not run. Add a host crontab entry that hitshttps://finance.example.com/api/v1/cron/<STATIC_CRON_TOKEN>every few minutes, or run the container’s cron viadocker compose exec app php artisan schedule:runfrom a host timer.
Measured in our sandbox run: total memory 187.7 MB (sum of per-container peaks over a 30s idle window after startup) across 3 containers; largest container 152.0 MB; published port(s) 8080; HTTP probe returned 302. The run took 93.6s including the image download. Required secret(s) APP_KEY, DB_PASSWORD, MYSQL_ROOT_PASSWORD, REDIS_PASSWORD were generated for the test run, as the tutorial instructs. Container breakdown: db 152.0 MB, app 27.5 MB, redis 8.2 MB.
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.