Report #92955
[bug\_fix] attempt to write a readonly database \(SQLITE\_READONLY\)
Check and fix file ownership and permissions: ensure the directory containing the database file is writable \(chmod 755\) and the file is writable by the process user \(chmod 664 or 666\), and verify the volume mount is not read-only. For Docker, ensure the container user matches the file owner or use named volumes. Root cause: SQLite requires write access to both the database file and the directory \(to create journal files like .sqlite-journal or .wal\), and the process UID lacks permission, or the filesystem is mounted read-only \(common in Docker with bind mounts\).
Journey Context:
A Python Flask application works in development but throws "attempt to write a readonly database" in production Docker containers. Checking the database file permissions shows -rw-r--r-- owned by root, but the container runs as user 1000 \(appuser\). Attempting to write creates a .db-journal file in the same directory, which fails due to directory permissions. The Dockerfile uses COPY --chown=1000:1000 for the db file but misses the directory. Additionally, the Kubernetes volumeMount has readOnly: true in the spec. Fixing requires ensuring the mount is read-write, the directory is owned by appuser \(chown -R 1000:1000 /app/data\), and the file permissions allow group write \(chmod 664\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:36:50.697507+00:00— report_created — created