Docker Community Forums

Share and learn in the Docker community.

How can I get to / edit the files from NextCloud container

When I go to my NextCloud container, it says

Please contact your administrator. If you are an administrator, edit the “trusted_domains” setting in config/config.php like the example in config.sample.php.

in /home/pi/website/nextcloud I see nothing, only my docker-compose.yml
as example in /home/pi/website/wordpress I see all the wordpress files! That’s what I like to see with NextCloud. My files are now stored in an image?

They are not. Depending wether you mounted a volume (or a bind-mount) to the volume or not, the volume path inside the container will either be written into the volume or the copy-on-write layer fo the container. While the first provides permanent persistance, the second does not!

Share your compose.yml and we shall see which one it is :slight_smile:

Though, some configurations are rendered thru the entrypoint script, which uses ENV variables to render the values into a template. If this is the case, changes to such rendered configuration files will be lost during the next start of the container. You need to make your self aquainted with the Dockerhub description for the particular image and see what the maintainer anticipated to be configured using ENV variables. If the ENV approach does not provide what you need, you can still start to hack around…

Here it is!

  version: '2'

    volumes:
      nextcloud:
      db:

    services:
      db:
        image: biarms/mysql
        command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
        restart: always
        volumes:
          - db:/var/lib/mysql
        environment:
          - MYSQL_ROOT_PASSWORD=password1
          - MYSQL_PASSWORD=password2
          - MYSQL_DATABASE=nextcloud
          - MYSQL_USER=nextcloud

      app:
        image: nextcloud
        ports:
          - 8080:80
        links:
          - db
        volumes:
    #    volumes: ['./:/var/www/html/files']
          - nextcloud:/var/www/html
        restart: always

I’m now in root@4e4127148eb6:/var/www/html/config# where I need tho edit the config.php, maybe that’s a step in the right direction? hahaha

Please check the dockerhub description first. Most cases are already anticipated by the image maintainer and can be easily achived with ENV variables.

In your case this should do the trick:

Images are build opinionated. Differnt images for the same software can be similar or complety different when it comes to what the entrypoint script are able to do. Depending on what the entrypoint script does you might find a different set of environment variables that can be declare for your container and will be used in the entrypoint script to do the “preparation magic” (like rendering config files) before the main process is started.

Can I place this in the docker-compose? Or how do I do this? Place the next code after volumes?

enviroment:
  - NEXTCLOUD_TRUSTED_DOMAINS=http://domain.com:8080

This is not working:

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: biarms/mysql
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password1
      - MYSQL_PASSWORD=password2
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    enviroment:
      - NEXTCLOUD_TRUSTED_DOMAINS=http://domain.eu:8080
    restart: always

I’m now in root@4e4127148eb6:/var/www/html/config# where I need tho edit the config.php, but I can’t open it with
sudo nano config.php

I also tried to search for a file that’s inside NextCloud, but you can quess it, no results

Actualy, it says list of domains. Though, you provided an URI, more specific an URL.
Try domain.com instead.

Appart from that the compose file looks fine.

Note: with additional environment variables on your app service, you could make Nextcloud automaticly use the database and bypass the installer:

  - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
  - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
  - NEXTCLOUD_TRUSTED_DOMAINS=${NEXTCLOUD_TRUSTED_DOMAINS}
  - MYSQL_HOST=${MYSQL_SERVICE_NAME}
  - MYSQL_DATABASE=${MYSQL_DATABASE}
  - MYSQL_USER=${MYSQL_USER}
  - MYSQL_PASSWORD=${MYSQL_PASSWORD} 

The values in ${} are just placeholders, replace them (including ${}) with your own values. The value for the MYSQL_* variables must match the values you actualy used on the mysql service.

Create New Data Directory & Mount Point. …
Modify Owner for New Data Directory. …
Copy Folders & Files to New Data Directory. …
Turn Maintenance Mode On. …
Edit fstab (File System Tables) Files. …
Edit config.php File to Add New datadirectory. …
Turn Maintenance Mode Off. …
Exit & Re-Start Nextcloud.

Oke trusted domain is done!

But where do I find the files on my Raspberry? There is no folder called /var/www/html/files to find…

It pretty much depends on the name of your volume, which depends on the project name (which defaults to the folder name):

docker volume inspect {project name}_nextcloud --format '{{.Mountpoint}}'

Well I don’t have to access it on the Raspberry, but after installing the Windows 10 application so I make backup on external hard drive on Windows :blush: so that point was not worth it hahaha

Oke, I found the folder! Thanks for that…
/var/lib/docker/volumes/nextcloud_nextcloud/_data
But when I’m in it, it says:

The specified directory ‘/var/lib/docker/volumes/nextcloud_nextcloud/_data’ is not valid

And no files are there, even when I show hidden files

I am not a Docker Desktop on Windows user. So can’t help you there.

Though, on Linux the folder should container content after you started the docker-compose stack ones.
Usualy the entrypoint script and the main process are responsible to write data into the volume.

Docker Desktop? Who’s talking about that? I uses a Raspberry with Docker Compose. I only use Windows to login in to Raspberry’s.

Appart from that: the volume only holds data after the container using it was started the first time.
Though, on a single node bind-mounts (as in -v /host/path:/container/path) are usualy fine as well, as long as the uid:gid of the owner of the host folder the match uid:gid of the process inside the container. Furthermore it’s possible to declare a volume baked by a bind (the forum search should returns several results for this), which behaves like a volume, but allows to define where the actual data folder is stored.

This post was flagged by the community and is temporarily hidden.