Permission denied: Can’t open directory for index: /var/www/html/

I’m using php-fpm and apache2 for making website with docker. I tried to dockerize the website.

But I got a problem :

Permission denied: Can’t open directory for index: /var/www/html/

apache2.conf (only interesting lines)

<Directory /var/www>
  Options Indexes FollowSymLinks
  AllowOverride None
  Require all granted
</Directory>

<Directory /var/www/html/public>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Inside my docker, the rights

drwxr-x--x  19 1000 1000   4096 Jan 16 10:21 .
drwxr-xr-x   1 root root   4096 Jan 22  2019 ..
-rw-r-----   1 1000 1000    214 Nov 21 13:11 .babelrc
drwxr-x---   8 1000 1000   4096 Jan  3 15:52 .git
-rw-r-----   1 1000 1000   5339 Jan  2 09:28 .gitignore
drwxr-x---   3 1000 1000   4096 Nov 22 16:02 .idea
drwxr-x---   4  999 1000   4096 Jan 17 08:15 .mariadb-data
-rw-r-----   1 1000 1000    966 Jan 16 14:00 Dockerfile
-rw-r-----   1 1000 1000   1548 Nov 21 13:11 LICENSE
-rw-r-----   1 1000 1000   9613 Jan  2 09:28 README.md
drwxr-x---   2 1000 1000   4096 Jan 16 08:10 apache
-rw-r-----   1 1000 1000    979 Nov 21 13:11 bitbucket-pipelines.yml
-rw-r-----   1 1000 1000    351 Nov 21 13:11 composer.json
-rw-r-----   1 1000 1000   9789 Jan  2 09:28 composer.lock
drwxr-x---   4 1000 1000   4096 Nov 21 13:11 config
drwxr-x---   4 1000 1000   4096 Nov 21 13:11 doc
-rw-r-----   1 1000 1000    718 Jan 10 15:15 docker-compose.yml
-rw-r-----   1 1000 1000   1812 Nov 21 13:11 init_autoloader.php
drwxr-x---   8 1000 1000   4096 Nov 21 13:11 language
drwxr-x---   3 1000 1000   4096 Jan  3 15:12 logs
drwxr-x---   4 1000 1000   4096 Nov 21 13:11 module
drwxr-x---   2 1000 1000   4096 Nov 21 13:11 nbproject
drwxr-x--- 641 1000 1000  24576 Jan 10 15:58 node_modules
-rw-r-----   1 1000 1000 313535 Jan 10 15:58 package-lock.json
-rw-r-----   1 1000 1000   1246 Jan 10 15:58 package.json
drwxr-x---   2 1000 1000   4096 Jan  2 09:28 php-fpm
drwxr-xr-x  11 1000 1000   4096 Jan 16 10:21 public
drwxr-x---   2 1000 1000   4096 Nov 21 13:11 tests
drwxr-x---   3 1000 1000   4096 Nov 21 13:11 tools
drwxr-x---   3 1000 1000   4096 Jan  2 09:39 var
drwxr-x---   7 1000 1000   4096 Jan 10 15:57 vendor

Docker-compose

version: '3.2'
services:
    mysql:
        image: mariadb:10.4
        container_name: mariadb
        restart: always
        ports:
            - 3306:3306
        environment:
            MYSQL_ROOT_PASSWORD: root
        volumes:
            - ./config/sql/schema.sql:/docker-entrypoint-initdb.d/schema.sql
            - ./.mariadb-data:/var/lib/mysql
    php:
        build: ./php-fpm
        container_name: php
        ports:
            - '9002:9000'
        volumes:
            - ./:/var/www/html/
        links:
            - mysql
    apache:
        build: .
        container_name: apache
        ports:
            - '8085:80'
        volumes:
            - ./:/var/www/html/

Dockerfile of apache

FROM php:5.6-apache

# Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install nodejs -y
RUN npm install [email protected] -g
RUN command -v node
RUN command -v npm

# Git
RUN apt-get update && 
    apt-get upgrade -y && 
    apt-get install -y git

COPY ./package*.json /var/www/html/

WORKDIR /var/www/html/

RUN npm install

ADD ./apache/docker-php.conf /etc/apache2/conf-available/docker-php.conf
ADD ./apache/docker-php.conf /etc/apache2/conf-enabled/docker-php.conf
ADD ./apache/apache2.conf /etc/apache2/apache2.conf

CMD apachectl -D FOREGROUND

I send all the code you need to find the problem. I tried to fix this error but I can’t.

The problem doesn’t seem to come from the docker. I only try to modify apache2 configuration.

My index.php is inside the public folder

Does anyone know how I can remove this ?

Source: StackOverflow