Can't write on data directory (docker instance)

Hi, I’m trying to setup Nextcloud following simply this official docker compose, but on the first setup I can’t access to data directory. I fill the data path /home/user/nextcloud/data , but I’m getting a permission error.

I’ve changed just the data and config volumes on the compose, and these two dir are created automatically on the first sudo docker-compose up (they’re owned by root of course).

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=passwd
      - MYSQL_PASSWORD=secret
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - ./config:/config
      - ./data:/data
    restart: always

and now you wonder why the web server process in the container can’t write to it?

Hi, I’ve seen that using the full path under the volume: ./data:/var/www/html/data and then leaving this default path /var/www/html/data on Nextcloud setup , it’s working and using the right external directory to save files.

If I use ./data:/data and then in Nextcloud setup I put /data as path directory I obtain the same permission error, while if I leave the default path, the setup completes but the data are stored inside the container, not outside on my data directory.

i’m not sure but i think if you use /var/www/html/data that folder is created by the entrypoint.sh on container startup and the ownership is set to the correct value. or?

Yes it’s right /var/www/html/data points in this way to my /home/user/nextcloud/data who is owned by root.

to my understanding it should be www-data. (id=33)

you can check with ps -ef which user runs the web server processes.

apache is run by http user.