<p>SELinux prevent the docker filesystem to work in the intended way, to fix this issue just add the :Z flag at the end of the volume declaration. It goes something like this:</p>

<pre><code>docker run -d -p 8080:80 -v {my_php_app_path}:/var/www/html:Z nimmis/apache-php7
</code></pre>

CC BY-SA 3.0
2018-01-16T06:05:06.790Z
2018-01-16T06:05:06.790Z
pievalentin
<p>I want to run my php website in a container with apache and php7 
I am using this docker image : <a href="https://hub.docker.com/r/nimmis/apache-php7/" rel="nofollow noreferrer">https://hub.docker.com/r/nimmis/apache-php7/</a></p>

<p>I run Fedora so I enter the example command given in docker hub in my terminal.</p>

<pre><code>docker run -d -p 8080:80 -v {my_php_app_path}:/var/www/html nimmis/apache-php7
</code></pre>

<p>The container pull and run fine. But once i try to access the asset (on localhost:8080) I mounted to it, I receive a 403 error. So now i try to connect to the container to see what happens. </p>

<p>I use the command adviced by the author:</p>

<pre><code>docker exec -ti &lt;container id&gt; /bin/bash
</code></pre>

<p>Once in it, I cd to /var/www/html all the file are presents but I cant read or ls in the folder. the root of the container cant do anythig with it. Here is what I get :</p>

<pre><code>&gt;&gt;&gt; root@a1f13dc4c29d:/var/www/html# ls
&gt;&gt;&gt; ls: cannot open directory '.': Permission denied
</code></pre>

<p>Why is it that way ? Am I missing a step ?</p>

<p>Any help would be loved :D</p>

<docker><linux><php><apache-httpd>
Apache container cant access php files mounted in /var/www/ - 403 error
pievalentin
# Apache container cant access php files mounted in /var/www/ - 403 error

(Asked by: username_0 on 2018-01-15)

I want to run my php website in a container with apache and php7 
I am using this docker image : https://hub.docker.com/r/nimmis/apache-php7/
I run Fedora so I enter the example command given in docker hub in my terminal.
docker run -d -p 8080:80 -v {my_php_app_path}:/var/www/html nimmis/apache-php7

The container pull and run fine. But once i try to access the asset (on localhost:8080) I mounted to it, I receive a 403 error. So now i try to connect to the container to see what happens. 
I use the command adviced by the author:
docker exec -ti  /bin/bash

Once in it, I cd to /var/www/html all the file are presents but I cant read or ls in the folder. the root of the container cant do anythig with it. Here is what I get :
>>> root@a1f13dc4c29d:/var/www/html# ls
>>> ls: cannot open directory '.': Permission denied

Why is it that way ? Am I missing a step ?
Any help would be loved :D

**Tags:** docker, linux, php, apache-httpd


---

## 1 answers

### Answer by username_0 on 2018-01-16. Score: 1

SELinux prevent the docker filesystem to work in the intended way, to fix this issue just add the :Z flag at the end of the volume declaration. It goes something like this:
docker run -d -p 8080:80 -v {my_php_app_path}:/var/www/html:Z nimmis/apache-php7


---

