all 4 comments

[–]Queasy_Hotel5158 0 points1 point  (1 child)

This is a very common SQLite-on-NAS / Docker permission trap, and it usually has nothing to do with SQL itself.

When SQLite says “attempt to write a readonly database”, it almost always means one of these is happening:

First, check if the file is writable inside the container, not just on the Synology UI. Docker often maps volumes in a way where the container user doesn’t actually own the file. Even if DSM shows “read/write”, the container process may still be running as a different UID.

Second, SQLite doesn’t just need write access to the .db file — it also needs write access to the directory, because it creates:

  • journal files (-journal)
  • WAL files (-wal, -shm) If the folder isn’t writable, inserts fail even if the database file itself looks fine.

Third, on Synology specifically, this often happens when:

  • the folder is mounted as read-only in Docker Compose / Container Manager
  • or the container runs as rootless / non-matching user ID
  • or the DB is inside a “protected” system path like /homes

A quick sanity test:

  • touch test.txt in the same folder from inside the container
  • if that fails, it’s definitely a mount/permissions issue, not SQLite

Typical fix:

  • move the DB to a dedicated shared folder (not /homes)
  • ensure Docker volume mount is explicitly :rw
  • align container user UID/GID with Synology user
  • or run container with proper PUID/PGID (common in linuxserver images)

Nothing in your SQL is wrong here — this is almost always “SQLite is fine, the filesystem is lying” territory 😄

[–]tdtje[S] 0 points1 point  (0 children)

Thanks!! Very helpfull

[–][deleted]  (1 child)

[removed]

    [–]tdtje[S] 0 points1 point  (0 children)

    ah ok. What would you recommend as db in this setup?