Permission Denied Accessing a Docker Container Config

I am at my wits end with this. I need to edit the config file for nextcloud so that I can add my tailnet to trusted domains, but no matter what I try, I cannot access the config.php for nextcloud.

when I enter the path into the CLI i get “permission denied” and no matter which commands I use (chown / usermod / etc) to adjust permissions, I still get denied.

what am I missing?

Most likely you are trying to reach the file from the host at the wrong path, or the file lives inside the container/volume and not where you expect.

On ZimaOS, do not fight it with random chown or usermod first. Confirm where config.php actually is.

Try this:

docker ps --format "table {{.Names}}\t{{.Image}}"

Find your Nextcloud container name, then inspect its mounts:

docker inspect <nextcloud-container-name> --format '{{range .Mounts}}{{println .Source "->" .Destination}}{{end}}'

Then either:

Option 1, edit from the host
If you see a mount that maps to Nextcloud web data, check for:

find /DATA/AppData -path "*nextcloud*" -name config.php 2>/dev/null

Option 2, edit from inside the container
This is often the cleaner way:

docker exec -it <nextcloud-container-name> sh
find / -name config.php 2>/dev/null

In most Nextcloud containers the file ends up here:

/var/www/html/config/config.php

Then edit it from inside the container with whatever editor exists, or print it first:

cat /var/www/html/config/config.php

If the issue is just host permission denied, also check who owns the file from the host side before changing anything:

ls -l /full/path/to/config.php
ls -ld /full/path/to /full/path/to/config

What you are probably missing is this:
the file is either inside the container filesystem, or in a Docker-mounted path owned by root, so changing permissions on the wrong host folder will do nothing.

Post the output of these 3 commands and it will be much easier to tell you the exact path:

docker ps --format "table {{.Names}}\t{{.Image}}"
docker inspect <nextcloud-container-name> --format '{{range .Mounts}}{{println .Source "->" .Destination}}{{end}}'
find /DATA/AppData -path "*nextcloud*" -name config.php 2>/dev/null

OK, I’ve gotten to here, with option 1 and 2;

@root:~ ➜ $ docker inspect nextcloud --format '{{range .Mounts}}{{println .Source "->" .Destination}}{{end}}'
WARNING: Error loading config file: open /DATA/.docker/config.json: permission denied
/DATA/AppData/nextcloud/var/www/html -> /var/www/html

@root:~ ➜ $ find /DATA/AppData -path "*nextcloud*" -name config.php 2>/dev/null
/DATA/AppData/nextcloud/var/www/html/config/config.php
@root:~ ➜ $ docker exec -it nextcloud sh
WARNING: Error loading config file: open /DATA/.docker/config.json: permission denied
# find / -name config.php 2>/dev/null
/var/www/html/config/config.php

And when I check who owns the file from the host side this is what is returned:

@root:~ ➜ $ ls -l /DATA/AppData/nextcloud/var/www/html/config/config.php
-rw-r----- 1 www-data www-data 812 Mar 20 17:57 /DATA/AppData/nextcloud/var/www/html/config/config.php
@root:~ ➜ $ ls -ld /DATA/AppData/nextcloud/var/www/html/config/config.php
-rw-r----- 1 www-data www-data 812 Mar 20 17:57 /DATA/AppData/nextcloud/var/www/html/config/config.php

from here i should be able to just enter

vim /var/www/html/config/config.php

right?

You’re very close, just one small misunderstanding.

That path:

/var/www/html/config/config.php

only works inside the container, not from the host.


From your current position (host)

You need to use the full host path:

vim /DATA/AppData/nextcloud/var/www/html/config/config.php

OR inside the container (cleaner)

Since you already did:

docker exec -it nextcloud sh

Then run:

vi /var/www/html/config/config.php

Why you got stuck

  • File is owned by www-data
  • Permissions are 640
  • So only:
    • owner (www-data)
    • or root
      can edit it

You are root, so you’re fine — but only if you use the correct path.


Ignore this warning (not your issue)

WARNING: Error loading config file: open /DATA/.docker/config.json: permission denied

That’s Docker CLI config, not Nextcloud, safe to ignore.


Bottom line

  • Host > use /DATA/AppData/...
  • Container > use /var/www/html/...
1 Like

You are a beautiful human being, friend.

1 Like