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

Will Marcouiller picture Will Marcouiller · May 24, 2018 · Viewed 15.6k times · Source

I'm new to Docker and currently following this tutorial:

Learn Docker in 12 minutes

I created the necessary files and I made it up to display "Hello World!" on localhost:80.

Beyond that point, I tried to mount the container using the direct reference to my folder so I can update the index.php file to mimic the development evironment, and then I come with this error:

Forbidden

All I did is change the way the image is ran so I can update the content of the index.php file and see the changes reflect in the webpage when I hit F5.

Currently using Docker for Windows on Windows 10 Pro

Docker for Windows is running

I followed every steps scrupulously so I don't get myself fooled and it didn't work for me it seems.

To answer Mornor's question, here is the result for docker ps

docker ps

And here for docker logs [container-name]

docker logs ae

And since I now better understand what happens under the hood, how do I go to solve my problem illustrated in the log?

Here is my Dockfile

Dockerfile

And the command I executed to run my image:

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

And so you see that the file exists:

path to index.php

Answer

Antti A picture Antti A · May 24, 2018

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.