Permissions issue for docker compose setup

The server is giving me the following in the logs:

Creating volume folders...

Creating hook folders...

Waiting for MySQL...

services are ready!

Waiting for Redis...

services are ready!

Writing config file...

Fixing base perms...

chown: changing ownership of '/var/www/owncloud/custom': Operation not permitted

chown: changing ownership of '/var/www/owncloud/config': Operation not permitted

My docker compose is as follows ( data is mapped to /MyMedia/owncloud is a folder from my NAS mounted using NFS )

version: "3"

volumes:
  files:
    driver: local
  mysql:
    driver: local
  redis:
    driver: local

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    container_name: owncloud_server
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - /MyMedia/owncloud:/mnt/data

  mariadb:
    image: mariadb:10.11 # minimum required ownCloud version is 10.9
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=owncloud
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=owncloud
      - MYSQL_DATABASE=owncloud
      - MARIADB_AUTO_UPGRADE=1
    command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - /config/owncloud/mysql:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    command: ["--databases", "1"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - /config/owncloud/redis:/data

My .env is as follows:

OWNCLOUD_VERSION=latest
OWNCLOUD_DOMAIN=localhost:8010
OWNCLOUD_TRUSTED_DOMAINS=localhost
ADMIN_USERNAME=username
ADMIN_PASSWORD=password
HTTP_PORT=8010

You can set OWNCLOUD_SKIP_CHOWN=true and OWNCLOUD_SKIP_CHMOD=true to disable the chown calls (which usually do not work on NFS shares as root is mapped to some unprivileged user on the NFS server).

You need to adjust the permissions and ownership of the files and folders manually then of course.

I see the permission errors for /var/www/owncloud . Have you considered setting the UID/GID of the user within the container to match the user that owns the directory on the host? This might solve the issue.

How would I figure that out… sorry, I’m pretty green.

After doing OWNCLOUD_SKIP_CHOWN=true and OWNCLOUD_SKIP_CHMOD=true, I’m now getting the error:

Could not open input file: /var/www/owncloud/occ

I don’t have an occ file in /var/www/owncloud, just config and custom directories.

Additionally, perhaps you could try creating a “candy bouquet” of permissions to see if that sweetens the deal.