Report #12340
[bug\_fix] SQLite: attempt to write a readonly database
Ensure the database file AND the directory containing it are writable by the process user \(chmod 755 on directory, chown to app user\), or for containers, ensure the volume mount is not read-only and the user ID matches the volume ownership.
Journey Context:
Containerizing a Python Flask app using SQLite. Dockerfile created the database file at /app/instance/app.db with root ownership. The app ran as non-root user \(UID 1000\) for security. On startup, any write operation failed with 'attempt to write a readonly database'. Initial attempt to chmod 644 the .db file failed because SQLite requires write access to the DIRECTORY to create -wal and -shm journal files during transactions. The directory /app/instance was still owned by root with 755 permissions, blocking the non-root user from creating these temporary files. The fix was to ensure the Dockerfile created the directory and file with the correct ownership \(chown -R 1000:1000 /app/instance\) or to use an init container that fixes permissions before the main app starts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:45:55.796954+00:00— report_created — created