TimWolla / docker-adminer

Database management in a single PHP file
https://hub.docker.com/_/adminer/
157 stars 69 forks source link

Getting a "attempt to write a readonly database" error for SQLite db #167

Open epicwhale opened 5 months ago

epicwhale commented 5 months ago

I am unable to figure out how why I am not able to edit the contents of the sqlite db from a directory I have mounted in my compose below. I tried the :rw suffix for the volume too, but I keep getting a "attempt to write a readonly database"

image

  adminer:
    image: adminer
    environment:
      - ADMINER_PASSWORD=${ADMINER_PASSWORD}
    volumes:
      - ./data:/data:rw
      - ./adminer-plugins/login-password-less.php:/var/www/html/plugins-enabled/login-password-less.php
    ports:
      - 8080:8080

My db is app.db in the data/ directory. I am having no trouble viewing the database in adminer, just all edit operations fail with the above error.

Can someone help me with me any pointers to resolve this? thanks in advance!

epicwhale commented 5 months ago

It looks like the docker container switches to a user 'adminer', where as anything I mount from the host container fails to be writeable by the 'adminer' user insider the container.

A temporary workaround I figured is updating the compose user to root like below:

  adminer:
    image: adminer
    environment:
      - ADMINER_PLUGINS=fc-sqlite-connection-without-credentials
    user: root  # without this, I can't write to sqlite file (as the container runs as an adminer user)
    volumes:
      - ./data:/data
      - ./adminer-plugins/fc-sqlite-connection-without-credentials.php:/var/www/html/plugins/fc-sqlite-connection-without-credentials.php
    ports:
      - 8080:8080

Anyone with a more elegant solution?