Report #82479
[bug\_fix] sqlite3.OperationalError: unable to open database file
Ensure the directory containing the database file exists and is writable by the application user. For Docker containers, create the directory in the Dockerfile and set appropriate ownership. Ensure the filesystem is not mounted read-only.
Journey Context:
You containerize a Python application using SQLite. Your docker-compose mounts a volume for persistence: \`./data:/app/data\`. The application code tries to connect to \`/app/data/prod.db\`. You get 'unable to open database file'. You exec into the container and find \`/app/data\` doesn't exist - SQLite won't create intermediate directories. You create the directory manually and it works, but on the next deploy it's gone. You update your Dockerfile to add \`RUN mkdir -p /app/data && chown -R appuser:appuser /app/data\`. You also realize that even if the file exists, if the directory isn't writable, SQLite can't create journal files \(like \`-shm\` and \`-wal\`\), so you ensure the permissions are 755 with correct ownership. After these changes, the application starts reliably in fresh containers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:02:10.880300+00:00— report_created — created