How can I solve 403:Forbidden whilst using a docker container? How can I solve 403:Forbidden whilst using a docker container? docker docker

How can I solve 403:Forbidden whilst using a docker container?


Error is coming from Apache which tries to show you the directory contents as there is no index file available. Either your docker mapping is not working correctly, or your apache does not have php support installed on it. You are accessing http://localhost, try http://localhost/index.php.

If you get same error, problem is with mapping. If you get php code the problem is with missing PHP support in Apache.


I think you're wrongly mouting your index.php. What you could do to debug it, is to firstly check if the index.php is indeed mounted within the container.
You could issue the following command :

docker run -p 80:80 -v /wmi/tutorials/docker/src/:/var/www/html/ hello-world bash -c 'ls -lsh /var/www/html/'

(use sh instead of bash if it does not work). If you can indeed see a index.php, then congratulations your file is correctly mounted, and the error is not coming from Docker, but from Apache.

If index.php is not there, then you have to check your Dockerfile. You mount src/, check if /src is in the same directory as your Dockerfile.

Keep us updated :)


I know the answer is late but the answer is very easy:this happens When using docker and you have SELinux, be aware that the host has no knowledge of container SELinux policy.by adding z

docker run -p 80:80 -v /wmi/tutorials/docker/src/:/var/www/html/:z hello-world

this will automatically do the chcon .... that you need to do.