Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forbidden in official image Docker PHP

Tags:

php

docker

apache

I'm testing the official image docker PHP:

docker run -d -p 8000:80 --name test php:7-apache

Then, I test http://localhost:8000, I find this:

Forbidden

You don't have permission to access / on this server.

What am I doing wrong?

like image 208
alvarezsh Avatar asked Jul 27 '16 02:07

alvarezsh


2 Answers

docker run -d -p 8000:80 --name test php:7-apache -v "$PWD":/var/www/html

Go to your project folder and run the above command or replace $PWD with your project directory. -v will sync your project to the docker container.

Or create a Docker file and use copy to run your project within the container.

Any one of the above will solve your problem. The probable reason for the error is the fact that there is no project to render.

like image 75
Deep Singh Baweja Avatar answered Nov 08 '22 11:11

Deep Singh Baweja


There's no hello world included with this image, /var/www/html/ is empty so there's no content to view. You need to bundle your own code in as the page on this image instructs:

We recommend that you add a custom php.ini configuration. COPY it into /usr/local/etc/php by adding one more line to the Dockerfile above and running the same commands to build and run:

FROM php:7.0-apache
COPY config/php.ini /usr/local/etc/php/
COPY src/ /var/www/html/
like image 33
BMitch Avatar answered Nov 08 '22 10:11

BMitch