I have three files:
Dockerfile:
FROM php:7.2-apache
COPY src/ /var/www/html
EXPOSE 80
docker-compose.yml:
version: '3'
services:
hello-world:
build: .
volumes:
- ./src:/var/www/html
ports:
- 80:80
src/index.php:
<?php
echo "Hello World!";
?>
I then run the command:
docker-compose up
And up until this point everything's fine, but when I access localhost in my browser I get:
403 Forbidden You don't have permission to access / on this server.
...and from the container the error message:
Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
However, if I from the docker-compose.yml file remove the 2 lines:
volumes:
- ./src:/var/www/html
...everything works fine (except the folder is not mounted). What am I doing wrong? It obviously doesn't like me mounting the volume, causing the directory /var/www/html/ to be empty, but why?