Unable to execute "occ file:scan" for new files copied (in a docker installation): lot of errors :(

Nextcloud version (eg, 20.0.5): 21.0.0 in a docker container
Operating system and version (eg, Ubuntu 20.04): OpenMediaVault debian based, latest
Apache or nginx version (eg, Apache 2.4.25): nginx 1.14.1
PHP version (eg, 7.4): 7.3.27
Is this the first time you’ve seen this error? (Y/N): N

Hi everybody,
I’m getting out crazy after hours of testing of a couple of machines, both with last OMV 5 + docker + portainer 2.1.1.
My goal is to install nextcloud (OK, done), copying my files into my physical folder user (OK, done, easy), let nextcloud “sees” them (problems raise here). I’ve already spent lot of time reading and trying, without success… please help me.

Let my say more.
For omv+docker I used the how-to step-by-step topic here, with a minor change (just nextcloud + mariadb for now, removed swag container), as you can see:

version: "2"
image: ghcr.io/linuxserver/nextcloud
container_name: nextcloud_test
- PUID=1003 #user docker1
- PGID=100
- TZ=Europe/Rome
- /nextcloud/config:/config
- /nextcloud/data:/data
- mariadb
- 30443:443
restart: unless-stopped
image: ghcr.io/linuxserver/mariadb
container_name: nextclouddb
- PUID=1003 
- PGID=100
- TZ=Europe/Rome
- /nextclouddb:/config
restart: unless-stopped

Now, everything is ok for installation part, but I want to copy my file inside nextcloud so I have to:

  1. copy them, of course, chowning them;
  2. run occ tool of nextcloud that allows the system to update the db metadatas with my files.

The second step is the problem.
First, I’ve got a missing module error on both systems and with

php -m

I noted that no mysql module is loaded.

So, I’ve installed it with

apt-get install php7.3-mysql

Then I execute again

sudo -u myUserName php occ file:scan


An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known in /nextcloud/config/www/nextcloud/lib/private/DB/Connection.php:85

Nextcloud seems to work, I mean I can add file via standard web interfaces, so we via cli it does not see the db?

Some note:

  • I remember some days ago I found a way that I forgot to solve this problem, maybe changing something in the trusted domains of config.php; occ file:scan started, but I had several and several authorization problems too.
  • I also have the same problems, or worst (no php module, but it is…) with sql-lite3.

Some other data:

The output of your Nextcloud log in Admin > Logging:

The output of config.php file in /path/to/nextcloud

$CONFIG = array (
'memcache.local' => '\\OC\\Memcache\\APCu',
'datadirectory' => '/data',
'instanceid' => '',
'passwordsalt' => '',
'secret' => '',
'trusted_domains' =>
array (
0 => '',
'dbtype' => 'mysql',
'version' => '',
'overwrite.cli.url' => '',
'dbname' => 'nextcloud',
'dbhost' => 'nextclouddb',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'oc_admin',
'dbpassword' => '',
'installed' => true,

Thank thank thank a lot for any suggestion and help!


e.g.: docker exec --user www-data nextcloud php occ files:scan admin

that means the user www-data in the container nextcloud executes the script file occ using php to scan all files of the user admin.

since you are using the image of the linuxserver guys I 'm not sure if they also use www-data as the user.

whatever you are trying to do, it’s seems totally wrong. e.g. are you running apt-get install ... on your host (omv)? that’s wrong and won’t change anything in your nextcloud container. and if you are running it inside your container, it’s wrong too. that’s a docker anti pattern.


on your host (omv) maybe. but not in your nextcloud container. it shouldn’t be. maybe the linuxserver folks do this.

bad idea. (on host and in container) the php occ command must run as the web server user. (with docker exec).

with the support of omv forum too, I finally have understood that the problem is the antipattern you named… I confused the container with the host activities! Shame on me! :frowning: (but I’m doing all of this for learning).
Thanks thanks thanks a lot!!!