Docker文件如下:
FROM php:7.2-apache
COPY src/ /var/www/html/
EXPOSE 80
已运行docker命令:
docker build -t hello-world .
docker run -p 80:80 hello-world
项目结构:
projectRoot
Dockerfile
src/index.html
当我这样做时,是什么导致许可被拒绝http://localhost:80
172.17.0.1 - - [08/Apr/2020:19:05:00 +0000] "GET / HTTP/1.1" 403 490 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
172.17.0.1 - - [08/Apr/2020:19:05:00 +0000] "GET / HTTP/1.1" 403 490 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
[Wed Apr 08 19:05:00.837027 2020] [autoindex:error] [pid 17] [client 172.17.0.1:40036] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
[Wed Apr 08 19:05:00.894055 2020] [autoindex:error] [pid 17] [client 172.17.0.1:40036] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
ADD
会将本地目录的内容复制到/var/www/html
,COPY
会将整个文件夹复制到/var/www/html
,所以apache找不到index.html,因为它将在这里/var/www/html/src/index.html
将dockerfile编辑为类似
FROM php:7.2-apache
ADD src /var/www/html/
EXPOSE 80