I try to use your example docker-compose. I just modified the domain, passwords and email to all use variables. I did put the nginx.conf file next to the docker-compose.yml file (and checked the permissions of those file).
But when I do
DOCKER_HOST=tcp://...:2376 DOCKER_TLS_VERIFY=1 \
DOMAIN="..." PASSWORD="..." EMAIL="..." docker-compose up
every container launches correctly except the web container:
ERROR: for web Cannot start service web: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/home/didier/Code/docker/nextcloud/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/770c4e28e5f59e3b7e1ff3fcbacecf011bffcbffda9853a95b412557f6c026f4/merged\\\" at \\\"/var/lib/docker/overlay2/770c4e28e5f59e3b7e1ff3fcbacecf011bffcbffda9853a95b412557f6c026f4/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Do you have any idea on how I can fix this ? I found this error a lot on the web but no working fix.
The error indicates that docker is trying to mount a single file (your nginx.conf) as a directory inside your container. Double check the docker command you used or the docker-compose file. (look for trailing slash or backslash).
@SnowMB OK, I figured it out. docker-compose cannot bind-mount local files to a remote docker.
I fixed it by doing a nginx build with Dockerfile:
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
and refer to it in my docker-compose.yml:
web:
image: nginx
build: ./nginx/
...
I had to do the same for nextcloud:fpm and nginx-proxy to provide them their configurations.
I'm now fighting docker because it assigns user root:root to named volumes and thus NextCloud can't read in /var/www/html/config and thus can't start...
Yeah, we are aware of that poblem. For now I would recommend using only one volume for nextcloud: The whole /var/www/html folder.
If you want to use multiple volumes you can change the permissions by hand. See #75.
OK, just to be sure let me show what I had so far. If ever this is related to #75 or #69, then I'll move there. Please forgive me if this is the case. I'm a docker beginner and permission management is painful. In advance, thanks for your help!
nextcloud:12.0-fpm experimentIn one terminal, I do:
> docker run --name test nextcloud:12.0-fpm
[19-Jun-2017 08:10:14] NOTICE: fpm is running, pid 1
[19-Jun-2017 08:10:14] NOTICE: ready to handle connections
In another terminal:
> docker exec -it test bash
root@f5cf4a19a450:/var/www/html# ls -l
total 124
drwxr-x---. 31 root www-data 4096 May 22 08:28 3rdparty
-rw-r-----. 1 root www-data 8868 May 22 08:25 AUTHORS
drwxr-x---. 36 root www-data 4096 May 22 08:26 apps
drwxr-x---. 2 www-data www-data 84 Jun 14 08:51 config
-rw-r-----. 1 root www-data 3717 May 22 08:25 console.php
drwxr-x---. 16 root www-data 4096 May 22 08:28 core
-rw-r-----. 1 root www-data 5057 May 22 08:25 cron.php
drwxr-x---. 2 www-data www-data 6 Jun 14 08:51 custom_apps
drwxr-x---. 2 www-data www-data 6 Jun 14 08:51 data
-rw-r-----. 1 root www-data 41077 May 22 08:25 db_structure.xml
-rw-r-----. 1 root www-data 179 May 22 08:25 index.html
-rw-r-----. 1 root www-data 2471 May 22 08:25 index.php
drwxr-x---. 3 root www-data 83 May 22 08:25 l10n
drwxr-x---. 6 root www-data 4096 May 22 08:25 lib
-rwxr-x--x. 1 root www-data 283 May 22 08:25 occ
drwxr-x---. 2 root www-data 89 May 22 08:25 ocs
drwxr-x---. 2 root www-data 22 May 22 08:25 ocs-provider
-rw-r-----. 1 root www-data 3152 May 22 08:25 public.php
-rw-r-----. 1 root www-data 5323 May 22 08:25 remote.php
drwxr-x---. 4 root www-data 49 May 22 08:25 resources
-rw-r-----. 1 root www-data 26 May 22 08:25 robots.txt
drwxr-x---. 14 root www-data 4096 May 22 08:25 settings
-rw-r-----. 1 root www-data 2110 May 22 08:25 status.php
drwxr-x---. 3 www-data www-data 45 May 22 08:25 themes
-rw-r-----. 1 root www-data 388 May 22 08:27 version.php
root@f5cf4a19a450:/var/www/html# ls -l config/
total 52
-rw-rw-r--. 1 root root 377 Jun 14 08:50 apps.config.php
-rw-r-----. 1 www-data www-data 46567 May 22 08:25 config.sample.php
As you can see the apps.config.php file is already root:root.
nextcloud:12.0-fpm experimentI have this Dockerfile (and sibling config.php file):
FROM nextcloud:12.0-fpm
COPY config.php /var/www/html/config/config.php
RUN chown www-data:www-data /var/www/html/config \
&& chown www-data:www-data /var/www/html/config/config.php
In one terminal, I do:
> docker build ./
Sending build context to Docker daemon 4.608 kB
Step 1/3 : FROM nextcloud:12.0-fpm
---> 078fdff8b9ae
Step 2/3 : COPY config.php /var/www/html/config/config.php
---> Using cache
---> 4d5d9aa75ebc
Step 3/3 : RUN chown www-data:www-data /var/www/html/config && chown www-data:www-data /var/www/html/config/config.php
---> Running in 6bfd199593bd
---> 2857c8555b90
Removing intermediate container 6bfd199593bd
Successfully built 2857c8555b90
> docker run --name test 2857c8555b90
[19-Jun-2017 08:10:14] NOTICE: fpm is running, pid 1
[19-Jun-2017 08:10:14] NOTICE: ready to handle connections
In another terminal:
> docker exec -it test bash
root@da18c7d11aee:/var/www/html# ls -l
total 124
drwxr-x---. 31 root www-data 4096 May 22 08:28 3rdparty
-rw-r-----. 1 root www-data 8868 May 22 08:25 AUTHORS
drwxr-x---. 36 root www-data 4096 May 22 08:26 apps
drwxr-xr-x. 2 root root 57 Jun 19 08:20 config
-rw-r-----. 1 root www-data 3717 May 22 08:25 console.php
drwxr-x---. 16 root www-data 4096 May 22 08:28 core
-rw-r-----. 1 root www-data 5057 May 22 08:25 cron.php
drwxr-x---. 2 www-data www-data 10 Jun 14 08:51 custom_apps
drwxr-x---. 2 www-data www-data 10 Jun 14 08:51 data
-rw-r-----. 1 root www-data 41077 May 22 08:25 db_structure.xml
-rw-r-----. 1 root www-data 179 May 22 08:25 index.html
-rw-r-----. 1 root www-data 2471 May 22 08:25 index.php
drwxr-x---. 3 root www-data 83 May 22 08:25 l10n
drwxr-x---. 6 root www-data 4096 May 22 08:25 lib
-rwxr-x--x. 1 root www-data 283 May 22 08:25 occ
drwxr-x---. 2 root www-data 89 May 22 08:25 ocs
drwxr-x---. 2 root www-data 30 May 22 08:25 ocs-provider
-rw-r-----. 1 root www-data 3152 May 22 08:25 public.php
-rw-r-----. 1 root www-data 5323 May 22 08:25 remote.php
drwxr-x---. 4 root www-data 49 May 22 08:25 resources
-rw-r-----. 1 root www-data 26 May 22 08:25 robots.txt
drwxr-x---. 14 root www-data 4096 May 22 08:25 settings
-rw-r-----. 1 root www-data 2110 May 22 08:25 status.php
drwxr-x---. 3 www-data www-data 45 May 22 08:25 themes
-rw-r-----. 1 root www-data 388 May 22 08:27 version.php
root@da18c7d11aee:/var/www/html# ls -l config
total 8
-rw-rw-r--. 1 root root 377 Jun 14 08:50 apps.config.php
-rw-r--r--. 1 root root 607 Jun 18 22:48 config.php
As you can see, the whole config/ directory and my config.php file both are root:root, despite the chown in my Dockerfile. When I use this in a docker-compose.yml, NextCloud fails to run until I manually do chown -R www-data:www-data config (and then it don't uses the database information in the config.php and I still can't connect to the database, but I guess those are unrelated).
Is this related to #75 or #69 ?
I run docker on my laptop with a remote DOCKER_HOST through tcp:.
> docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 102
Server Version: 17.03.1-ce
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: false
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.11.5-200.fc25.x86_64
Operating System: Fedora 25 (Twenty Five)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 2
CPUs: 4
Total Memory: 15.57 GiB
Name: [REMOVED]
ID: [REMOVED]
Docker Root Dir: /data/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
127.0.0.0/8
Registries:
Do you need more info ?
Hey,
You used the wrong folder. Let me explain:
First you have to know that the whole /var/www/html folder is defined as a volume in the original Dockerfile. That implies, that this directory cannot contain any data, because whenever a container is started the volume will be mounted and anything that is in this folder or subfolders will be hidden by the volume.
So the file you copied into the volume is replaced by the default config file.
If you check the docker-entrypoint.sh script you will see that on first run the actual nextcloud data is copied from the directory /usr/src/nextcloud/. If you want to make a derived Dockerfile with your data in it, place it in that directory.
@SnowMB Oh I see! Thank you, that part now works – I don't have a blank page!
(I still have to understand why the database informations in my generated configuration are not automatically used and why it says SQLSTATE [HY000][1130] when I try to create the admin account but it is a great step...)
BTW, maybe I missed something in the documentation but using /usr/src/nextcloud was not obvious !
(But again I'm new to docker...)
Yeah I'm sorry, but until now I did not anticipate to manipulate the sources directly.
But I think this is an elegant solution for problems like yours and #91. I wrote a quick hint there. So thanks for the idea 😄 .
I will add this to the examples to do list.
@SnowMB Also in the docker-compose examples the version prefix for nextcloud is missing (i.e. :12.0-apache, :12.0-fpm).
you're right. thanks again 😁
Most helpful comment
@SnowMB OK, I figured it out. docker-compose cannot bind-mount local files to a remote docker.
I fixed it by doing a nginx build with Dockerfile:
and refer to it in my
docker-compose.yml:I had to do the same for
nextcloud:fpmandnginx-proxyto provide them their configurations.I'm now fighting docker because it assigns user root:root to named volumes and thus NextCloud can't read in /var/www/html/config and thus can't start...