Data directory invalid, check for file ".ocdata"

hey i am running nextcloud in a docker container for several years successfully. I just wanted to update my nextcloud instance to latest release and noticed this message in dashboard:

" Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory."

I never moved my data directory for years btw. There is a .ocdata file located in my mounting point which is /mnt/NC/:

[user@nuc files]$ sudo ls -la /mnt/NC/
[sudo] Passwort für user:
insgesamt 19021
drwxrwx--- 1 http http     4096  1. Jan 2023  .
drwxr-xr-x 4 root root     4096  7. Feb 2021  ..
drwxrwx--- 1 http http     4096  1. Aug 16:59 appdata_ocst4wxqk0vi
drwxrwx--- 1 http http     4096  5. Aug 2022  user1
-rwxrwx--- 1 http http      542 25. Mär 2022  .htaccess
-rwxrwx--- 1 http http        0 25. Mär 2022  index.html
drwxrwx--- 1 http http        0 25. Jul 2022  user2
-rwxrwx--- 1 http http 19456788 27. Dez 07:54 nextcloud.log
-rwxrwx--- 1 http http        0 25. Mär 2022  .ocdata

Right now i am running Nextcloud Hub II (23.0.3)

your directory looks OK at first glance. user is 33:33 by default often it maps to www-data, but might be different depending on distribution… user rights of 770 are not common - 750/640 is default but likely this is not the root cause. Please share more details especially your docker run command or docker compose file…

This is my docker-compose file:

version: '3'

services:
  db:
    image: mariadb:10.5
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD='<my5up3r53cr37p455w0rd#'
    env_file:
      - db.env

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:apache
    restart: always
    volumes:
      - /home/user/docker-compose-files/nextcloud/nextcloud:/var/www/html
      - /mnt/NC:/var/www/html/data
    environment:
      - VIRTUAL_HOST=my.server.com
      - LETSENCRYPT_HOST=my.server.com
      - LETSENCRYPT_EMAIL=mail@server.com
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis
    networks:
      - proxy-tier
      - default

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

  proxy:
    build: ./proxy
    restart: always
    ports:
      - 80:80
      - 443:443
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    volumes:
      - certs:/etc/nginx/certs:ro
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - proxy-tier

  letsencrypt-companion:
    image: nginxproxy/acme-companion
    restart: always
    volumes:
      - certs:/etc/nginx/certs
      - acme:/etc/acme.sh
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - proxy-tier
    depends_on:
      - proxy

# self signed
#  omgwtfssl:
#    image: paulczar/omgwtfssl
#    restart: "no"
#    volumes:
#      - certs:/certs
#    environment:
#      - SSL_SUBJECT=servhostname.local
#      - CA_SUBJECT=my@example.com
#      - SSL_KEY=/certs/servhostname.local.key
#      - SSL_CSR=/certs/servhostname.local.csr
#      - SSL_CERT=/certs/servhostname.local.crt
#    networks:
#      - proxy-tier

volumes:
  db:
  nextcloud:
  certs:
  acme:
  vhost.d:
  html:

networks:
  proxy-tier:

User 33:33 should be right, inside docker container:

docker exec -it 36e10a0d4b8b /bin/bash
root@36e10a0d4b8b:/var/www/html# cat /etc/passwd
[...]
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
[...]

And on my host system:

[user@nuc ~]$ grep "http" /etc/passwd
http:x:33:33::/srv/http:/usr/bin/nologin

The problem is still not solved.

As you can see, my data directory is /mnt/NC which is a mounted drive. .ocdata file is located right there. Next thing: I noticed, that i can’t see the log files in web interface. I’ll get the error Could not load log entries but the file is located in /mnt/NC/nextcloud.log. I can see the content with tail -f /mnt/NC/nextcloud.log from my host system. Are these issues related to each other?

Please keep calm! this forum is driven by volunteers and nobody is obliged to spend time on your issue!


review you volume mounts. https://github.com/nextcloud/docker#persistent-data

I feel it is not common to mount top-level /var/www/html to one directory and a child directory /var/www/html/data to another destination. Please review if there is another copy of /var/www/html/data in the host /home/user/docker-compose-files/nextcloud/nextcloud maybe it takes precedence over mnt/NC

maybe you get better insights using docker inspect <container name> command. container name may vary… as long I get you setup right it could be nextcloud-app-1 - review with docker-compose ps

Please keep calm!

I think there has been a misunderstanding here.

My point was simply that I found another problem that could be related to the original problem. Before it is now incorrectly assumed that the original problem has been solved, and I have a new one, I just wanted to clarify this as an opening sentence. I’m not being impatient or pointing the finger at volunteers, I just wanted to make it clear that my initial problem still exists; quite simply and objectively and not emotionally. I am grateful for any help and therefore also very grateful for your help.

Okay. Regardless of this, fun fact: the problem has actually been solved. So not the logging problem which i mentioned later, but the .ocdata error. I had to restart my containers several times for reasons and tweaked the docker-compose.yml a bit. In the end it was probably due to several restarts and the fact that I haven’t updated my NC instance for a while. Whatever the reason, the message is gone.

But while we were on the subject:
As /var/www/html/data/ are my personal data (files, pictures and so on) and /var/www/html the files for appache, i want to separate them. I don’t want stuff which is located in /var/www/html/ on my external hard drive which is only for my personal data. So i thought this is a good workaround, isn’t it?

1 Like

I’m not sure how such top-level/child-level volume mount is expected to work. definitely it’s not very easy to understand. see the reference I provided - you can definitely separate the 3 mounts for apps, data and config (which IMHO you should keep close to data).

AFAIK there is no need to persist anything else than this 3 directories and you can leave under container control.

if mounting additional volumes, you should note that data inside the main folder (/var/www/html) may be removed during installation and upgrades…

for the log problem use search there is an issue with nc28 which is fixed with 28.0.1