Not showing files in /data that are mapped by docker

I set up nextcloud by this command:
docker run --name nextcloud -p 9980:80 -itd --link nextcloud_psql:nextcloud_psql --restart=always -v /mnt/raid1/:/data docker.io/nextcloud

After setting up, nextcloud are not showing any of the files that I have mapped by -v/mnt/raid1/:/data in the webui. But

docker exec  -it nextcloud bash
cd /data
ls -la

Can show all the data I have.
I have tried occ files:scan --all but that didnt work.

Hi,
that might be a permission thing. Are you able to check, if the container user has access to your mounted /data folder?

docker exec -it nextcloud bash


The permission seemed to be correct

  1. Please provide your config.php
  2. Is this a new installation or one that’s been functioning? (i.e. you’ve accessed these files, mounted in this way, from NC)
  3. You can’t check permissions or run occ commands properly as root. You need to be appending -u1001 to your exec commands from the looks of the permissions you provided.
  4. The permissions and ownership of all the subdirectories under data matter as well. Check them. You’re more likely to encounter these issues since you’re using bind mounts rather than naked volumes. Bind mounts | Docker Documentation

Update: Actually now that I look at it closer your file permissions are definitely not right. The 1001 should match an id recognized by the docker container. Usually that’d be www-data/33.

Hi, thanks for your reply.

root@6d68d80827ab:/var/www/html# cat /var/www/html/config/config.php
<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'ocl35623917y',
  'passwordsalt' => 'hsijh+M++bAmwVWuYHKNTCSpm9I/1V',
  'secret' => 'DESlr6UXjUbQVrK7ekdkBG3Q8cvETSp50aDqSSpdVYjz4PFA',
  'trusted_domains' =>
  array (
    0 => '192.168.1.144:9980',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '26.0.1.1',
  'overwrite.cli.url' => 'http://192.168.1.144:9980',
  'dbname' => 'nextcloud',
  'dbhost' => '172.17.0.6:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_yue',
  'dbpassword' => '3NT960ibdHxjWu8paWCaK1ZoubaoEg',
  'installed' => true,
);

It is a new installation on Docker.
I have ran occ with -u 33 as recommanded when I ran occ with the default user:

root@6d68d80827ab:/var/www/html# ./occ
Console has to be executed with the user that owns the file config/config.php
Current user id: 0
Owner id of config.php: 33
Try adding 'sudo -u #33' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u 33' to the docker command (without the single quotes)

Okay you have a couple of issues:

  1. You need to persist your /var/www/html not just wherever you’re placing your literal data.

  2. Nextcloud is expecting your data folder to be in /var/www/html/data not /data.

Try this:

docker run --name nextcloud -p 9980:80 -itd --link nextcloud_psql:nextcloud_psql --restart=always -v /mnt/raid1/:/var/www/html/data -v nextcloud:/var/www/html docker.io/nextcloud

This will use your /mnt/raid1 as your Nextcloud data directory (a persistent bind volume in Docker) and will also tell Docker to create a persistent internally managed named volume to store your Nextcloud configs/apps.

Or, even simpler:

docker run --name nextcloud -p 9980:80 -itd --link nextcloud_psql:nextcloud_psql --restart=always -v /mnt/raid1/:/var/www/html docker.io/nextcloud


Also, as an aside but possibly a timely one: I would suggest you explore switching to using a Docker Compose file for your stack so it’s less fragile (and way easier to keep sane).

Okay I fear my sleepiness is making this less clear than I’d like so I cleaned this post up of most of the rambling hah.

I ran into this after setting up:

You’re nextcloud.log will likely tell you the issue.

However since you previously started the same container differently you may simply have inconsistent stuff around. Since this was a fresh install I assume there was nothing of importance in the nextcloud container you ran with the prior mount point, correct? If so:

docker stop nextcloud
docker rm nextcloud

Then reattempt the docker run [...]

I’ll make two other suggestions:

  • You probably don’t want -itd but I’m not sure of your goals. Generally I’d expect just -d. Combining all three is somewhat mutually exclusive.
  • Consider using a Docker Compose file instead of running and defining all this stuff manually. It will make your stack easier to configure, update, and keep straight.
1 Like