简体   繁体   中英

docker php:7.4-apache container, unable to get the page pull up in localhost

i successfully created a php_apache image by going to the specified directory with following command docker build -t php_apache

my docker file is

FROM php:7.4-apache
COPY Php_demo_project/ var/www/html/
EXPOSE 80

but while running the image with following command

docker run -it --rm --name php_demo_container -p 80:80 php_apache

am unable to get the page in browser, and when I search for localhost 404 forbidden access like showing enter image description here

when I enter localhost in chrome in command line it is showing as

[Wed Jun 24 01:29:19.895025 2020] [autoindex:error] [pid 16] [client 172.17.0.1:42010] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

172.17.0.1 - - [24/Jun/2020:01:29:19 +0000] "GET / HTTP/1.1" 403 491 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"

am unable to find where the error is.. what am I missing?????????

Make sure your files have read access rights:

FROM php:7.4-apache
COPY Php_demo_project/ /var/www/html/
RUN chmod -R a+r /var/www/html/
EXPOSE 80

I think this will help you:

FROM php:7.4-apache
COPY Php_demo_project/ /var/www/html
RUN chown -R www-data:www-data /var/www
EXPOSE 80

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM