title: Nginx cannot access a Docker volume mount
body: <p>I have a Docker Compose setup to run a Nginx serving pictures (<code>jpg</code> files). The port, protocol, etc. is not relevant. My Nginx works correctly and serve those files:</p>
  
  <pre><code> web:
    image: myweb
    restart: always
    volumes:
   - ./logs/nginx:/var/log/nginx
    ports:
   ...
  </code></pre>
  
  <p>The image <code>myweb</code> inherits from <code>nginx</code> and add all the configuration needed by this server, basically, the web root is:</p>
  
  <pre><code>  index index.html index.php;
    root /var/www/myweb/public;
  </code></pre>
  
  <p>I'm also using <code>php:7.0-fpm</code> and <code>fastcgi</code> locations but it is not the issue here.</p>
  
  <p>What I would want is to <strong>mount a host volume with the pictures</strong> (instead of copying them into the <em>docker image</em>) in order to have the possibility of update it externally (Dropbox sync or whatever).</p>
  
  <pre><code> web:
    image: myweb
    restart: always
    volumes:
   - ./webcode:/var/www
   - ./logs/nginx:/var/log/nginx
   - ./images-data/catalog-images:/var/www/myweb/public/catalog/images
    ports:
   ...
  </code></pre>
  
  <p>The host path <code>webcode</code> (relative to <em>docker-compose.yml</em> location) is the static web, also mounted on <code>/var/www</code>.
  The host path <code>images-data/catalog-images</code> (relative to <em>docker-compose.yml</em> location) is the pictures directory, mounted on <code>/var/www/myweb/public/catalog/images</code>.</p>
  
  <p>I'm not sure it this is a good practice (mount a host directory on the same path where other host directory was already mounted). Anyway, I also tried keeping <code>webcode</code> as part of the <code>myweb</code> image having only one mounted volume (the pictures one).</p>
  
  <p>Mounting <code>webcode</code> and including pictures on it, works. And without any volume mount, just including all the stuff (website and pictures), also works. But I would need to have an isolated volume for the pictures.
  I also tried symlinking within the container <code>/var/www/myweb/public/catalog/images</code> towards the pictures volume. But Nginx does not render it, perhaps because it it a different volume than <code>/var/www</code>.</p>
  
  <p>Should it belong to the <code>root</code> of <code>nginx</code> server configuration ?</p>
  
  <p>The thing is that, those images are not loaded in the browser. Going into the container, I confirm that the ownership for the volume is correct (<code>www-data:www-data</code>).</p>
  
  <p>From the point of view of the container, ownership and content is the same if I mount the volume or if I copy in the container filesystem. But Nginx only can see the files within the Docker container file system.</p>
  
  <p>Is this the normal behaviour ? Am I missing any Nginx configuration to work normally with host volumes inside the container ?</p>