Skip to content

Database

This content is for v1.0. Switch to the latest version for up-to-date documentation.

Variable Default Description
DB_DRIVER sqlite Database backend: sqlite or postgres.
DB_SQLITE_PATH data/klokk.db Path to the SQLite file. The default lies in /app/data, the container volume — mount it so the database survives updates. A klokk.db at the former default location (working directory) is still used if present.
DB_DSN — PostgreSQL connection string, e.g. postgres://user:pass@host:5432/db?sslmode=disable. Required when DB_DRIVER=postgres.
DB_MAX_OPEN_CONNS 25 Max open DB connections (PostgreSQL only).
DB_MAX_IDLE_CONNS 5 Max idle DB connections (PostgreSQL only).
DB_CONN_MAX_LIFETIME_MINUTES 5 Connection max lifetime in minutes (PostgreSQL only).

Update note — SQLite without DB_SQLITE_PATH

Images before v1.0.0 stored the database at /app/klokk.db, outside the volume. If you started Klokk with the quick start and did not set DB_SQLITE_PATH, copy the database into the volume once before updating — at a quiet moment, while nobody is clocking in:

docker exec klokk sh -c '[ -f /app/klokk.db ] && [ ! -e /app/data/klokk.db ] && cp -p /app/klokk.db /app/data/klokk.db && echo copied'

With Docker Compose use docker compose exec klokk …. Then update as usual; the new version uses /app/data/klokk.db. Installations that already set DB_SQLITE_PATH=/app/data/klokk.db need no action.