Where is `config.php` in Windows Docker setup?

According to: https://stackoverflow.com/questions/19234831/where-are-docker-images-stored-on-the-host-machine and https://blog.jongallant.com/2017/11/ssh-into-docker-vm-windows/

You can’t directly access/browse the files within the docker images directly, but you can still access them with:
0. open cmd

  1. enter:
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client 
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
chroot /host
  1. Then you’re into the linux file system that is used by docker, and I presume you can then locate your nextcloud config.php with (assuming it is in /var/lib/):
cd ..
cd ..
cd var/lib/
find . -name "config.php"

That results in the list of all config.php files within directory /var/lib/. Then you should find the nextcloud one, I think you should use the long code you get when you enter:

docker run -d -p 8080:80 nextcloud

To identify the correct instance of the config.php files, but I have not tested it yet.

You can display the contents of the config.php file with cat config.php after browsing into the correct directory. However I do not yet know how to edit the file as nano and vim are not available through the cmd bash. Furthermore, the config.php file consists of the php code that renders the interface through which one can set the configuration, instead of a storage of the actual configurations which I intended to modify. Therefore I would have to look further to identify the correct file to modify to satisfy the xy-problem.

Since Nano is not available in the ubuntu version downloaded in docker by the commands specified at 1, one can use the cat command to modify files.

  1. Browse into the directory that contains the config.php file.
  2. Display the content of the config.php file by typing:
cat config.php

Copy that content.
6. Paste and edit the copied content in a windows editor, e.g. notepad++
5. Re-open cmd Delete the config.php with:

rm config.php
  1. Re-create the file and enter its content by:
cat > config.php
  1. RMB in the command window to paste the content
  2. Press ctrl+c to end entering lines to the file.
  3. That should be it, verify again with cat config.php
1 Like