NC does not set the correct write permissions data dir at initial startup with Docker-Compose

Hi,

hope that I get help here. I have tried a lot of things, but did not get the desired behavior. I would like to have after the init start of NC automatically the correct rights in the data folder.

drwxr-xr-x    2 www-data root          4096 Nov 19 15:01 custom_apps
drwxr-xr-x    2 root     root          4096 Nov 19 15:01 data
-rw-r--r--    1 www-data root           156 Nov 19 15:01 index.html

The desired behavior would be here also with the data Order www-data as user.

version: '3.9'

networks:
  proxy:
    external: true
    name: loadb-net

volumes:
    nextcloud-www:
        name: ${NEXTCLOUD_VOL_WWW}  
        driver: local      
    nextcloud-data:
        name: ${NEXTCLOUD_VOL_DATA}  
        driver: local        
    nextcloud-db:                 
        name: ${NEXTCLOUD_VOL_DB}   
        driver: local               
    nextcloud-redis:             
        name: ${NEXTCLOUD_VOL_REDIS}
        driver: local

services:

  nextcloud-db:
    image: mariadb:10.5
    container_name: nextcloud-db
    command: --transaction-isolation=READ-COMMITTED --log-bin=ROW # --innodb_read_only_compressed=OFF
    restart: unless-stopped
    volumes:
      - nextcloud-db:/var/lib/mysql
    environment:
      - MARIADB_USER=${MARIADB_USER}
      - MARIADB_PASSWORD=${MARIADB_PASSWORD}
      - MARIADB_DATABASE=${MARIADB_DATABASE}
      - MARIADB_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_INITDB_SKIP_TZINFO=1
    networks:
      - default


  nextcloud-redis:
    image: redis:alpine
    container_name: nextcloud-redis
    hostname: nextcloud-redis
    networks:
        - default
    restart: unless-stopped
    command: redis-server --requirepass ${NEXTCLOUD_REDIS_PASSWORD}
    volumes:
        - nextcloud-redis:/var/lib/redis

  nextcloud-app:
    image: nextcloud:fpm-alpine
    container_name: nextcloud-app
    restart: unless-stopped
    depends_on:
      - nextcloud-db
      - nextcloud-redis
    environment:
      - MYSQL_HOST=nextcloud-db
      - MYSQL_USER=${MARIADB_USER}
      - MYSQL_PASSWORD=${MARIADB_PASSWORD}
      - MYSQL_DATABASE=${MARIADB_DATABASE}
      - REDIS_HOST=nextcloud-redis
      - REDIS_HOST_PASSWORD=${NEXTCLOUD_REDIS_PASSWORD} 
      - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
      - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
      - NEXTCLOUD_TRUSTED_DOMAINS=cloud.${DOMAIN}
      - TRUSTED_PROXIES=172.21.0.2/16
    volumes:
      - nextcloud-www:/var/www/html
      - nextcloud-data:/var/www/html/data
    networks:
      - default

  web:
      build: ./web
      container_name: nextcloud-web
      restart: unless-stopped
      networks:
        - default
        - proxy
      volumes:
        - nextcloud-www:/var/www/html:ro
      depends_on:
        - nextcloud-app
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.nextcloud-app.entrypoints=web"
        - "traefik.http.routers.nextcloud-app.rule=Host(`cloud.${DOMAIN}`)"
        - "traefik.http.middlewares.nextcloud-app-https-redirect.redirectscheme.scheme=https"
        - "traefik.http.routers.nextcloud-app.middlewares=nextcloud-app-https-redirect"
        - "traefik.http.routers.nextcloud-app-secure.entrypoints=websecure"
        - "traefik.http.routers.nextcloud-app-secure.rule=Host(`cloud.${DOMAIN}`)"
        - "traefik.http.routers.nextcloud-app-secure.tls=true"
        - "traefik.http.routers.nextcloud-app-secure.tls.certresolver=le-prod"
        - "traefik.http.routers.nextcloud-app-secure.service=nextcloud-app"
        - "traefik.http.services.nextcloud-app.loadbalancer.server.port=80"
        - "traefik.http.routers.nextcloud-app-secure.middlewares=nextcloud-dav,nextcloud-headers"
        - "traefik.http.middlewares.nextcloud-dav.replacepathregex.regex=^/.well-known/ca(l|rd)dav"
        - "traefik.http.middlewares.nextcloud-dav.replacepathregex.replacement=/remote.php/dav/"
        - "traefik.http.middlewares.nextcloud-headers.headers.hostsproxyheaders=X-Forwarded-Host"

  cron:
    image: nextcloud:fpm-alpine
    restart: always
    volumes:
      - nextcloud-www:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - nextcloud-db
      - nextcloud-redis

The cron container reports in the log that it has no rights on the data folder.

shouldn’t the cron container have access to - nextcloud-data:/var/www/html/data as well?

and what do you call “correct permissions”? root:root is wrong. or?

1 Like

Thank you very much for the help. That was the solution. Adding the data folder - nextcloud-data:/var/www/html/data helped. now the folder also has the correct rights www-data