Docker image to work with existing nginx and php7 containers


#1

Hello,

I am quite new to docker. I have setup a nginx container which communicates with a container running php:7-fpm. It servers .php files sucessfully. My intention is now, to have a docker image of owncloud, which only includes the necessary files to be served by my nginx container. I tried with the image owncloud:fpm, but this does not work in my setup since I am getting the following errors trying to access owncloud:

2017/10/01 09:05:13 [error] 6#6: *12 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.20.0.1, server: example.com, request: "GET /owncloud/index.php HTTP/1.1", upstream: "fastcgi://172.20.0.3:9000", host: "example.com"

My nginx.conf is:

    server {
    index index.php index.html;
    server_name example.com;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
      	include fastcgi_params;
      	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      	fastcgi_param PATH_INFO $fastcgi_path_info;
      	fastcgi_param HTTPS on;
      	fastcgi_pass php:9000;
      	fastcgi_intercept_errors on;
    }
}

And my docker-compose.yml:

version: "3"

services:
    web:
        image: nginx:latest
        container_name: "nginx"
        restart: always
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - /var/www:/var/www
            - ./site.conf:/etc/nginx/conf.d/site.conf
            - ./nginx.conf:/etc/nginx/nginx.conf
            - owncloud-www:/var/www/owncloud
            - /var/log/nginx:/var/log/nginx
        links:
            - owncloud

    php:
        image: php:7-fpm
        container_name: "php7"
        restart: always
        ports:
            - "9000:9000"
        volumes:
            - "/var/www:/var/www"
owncloud:
        image: owncloud:fpm
        container_name: owncloud
        volumes:
            - owncloud-www:/var/www/html

volumes:
    owncloud-www:

Any hint on whats the issue with this setup?


#2

Maybe our official docker files can give a hint: https://doc.owncloud.org/server/latest/admin_manual/installation/docker/
We are however building with Apache as default. Github repo is here: https://github.com/owncloud-docker/server


#3

I think the nginx config is wrong. There is one looking completely different available at https://doc.owncloud.org