title: Use volume mounting for app behind Nginx with shared volume access
body: <p>I've got a Python web app that runs inside two Docker containers, one for the FastAPI backend, the other for the Vue.JS front-end (and there's besides a third one, with the Postgres Db). To enable access to the front-end (for image uploads) from the back-end, I should need to use Docker volumes.</p>
  <p>My Docker compose file looks like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.8&quot;
  
  services:
  
    use_frontend:
      container_name: 'use_frontend'
      # --&gt; ADDED &lt;--
      volumes:
        - 'myshare:/etc/nginx'
        - 'myshare:/usr/share/nginx/html'
      build: 
        context: ./admin
        dockerfile: Dockerfile
      restart: always
      depends_on:
        - use_backend
      ports:
        - 8090:80
  
    use_db:
      container_name: use_db
      image: postgres:14.2
      # etc etc...
  
    use_backend:
      container_name: 'use_backend'
      volumes:
        # --&gt; ADDED &lt;--
        - 'myshare:/usr/share/nginx/html'
      build: 
        context: ./api
        dockerfile: Dockerfile
      restart: always
      depends_on:
        - use_db
      # etc etc...
  
  # --&gt; ADDED &lt;--
  volumes:
    myshare:
      driver: local
  </code></pre>
  <p>The <code>Dockerfile</code> for <code>use_frontend</code> hasn't changed (must it?)</p>
  <pre class="lang-mk prettyprint-override"><code>FROM node:16.14.2 as builder
  
  WORKDIR /admin
  
  # copy out files for npm
  COPY package*.json ./
  COPY vite.config.js ./
  
  # install and build Vue.js
  RUN npm install
  COPY . .
  RUN npm run build
  
  # Nginx image
  FROM nginx:1.21
  
  # copy Nginx conf file to VOLUME mounted folder
  COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
  # clean everything in VOLUME mounted folder (app entry point)
  RUN rm -rf /usr/share/nginx/html/*
  # copy compiled app to to VOLUME mounted folder (app entry point)
  COPY --from=builder /admin/dist /usr/share/nginx/html
  
  # expose port 80 for HTTP access
  EXPOSE 80
  
  # run Nginx
  CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
  </code></pre>
  <p>The Nginx conf file hasn't changed either:</p>
  <pre class="lang-python prettyprint-override"><code>events {}
  
  http {
      server {
          listen 80;
          # app entry point
          root /usr/share/nginx/html;
          # MIME types
          include /etc/nginx/mime.types;
          
          client_max_body_size 20M;
  
          location / {
              try_files $uri /index.html;
          }
  
          # etc etc...
      }
  }
  </code></pre>
  <p>But after doing</p>
  <pre class="lang-sh prettyprint-override"><code>docker compose build
  docker compose up
  </code></pre>
  <p>I'm getting <code>file not found</code> errors from Nginx:</p>
  <pre><code>use_frontend  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
  use_frontend  | /docker-entrypoint.sh: Configuration complete; ready for start up
  use_frontend  | 2022/07/24 23:21:32 [emerg] 1#1: open() &quot;/etc/nginx/nginx.conf&quot; failed (2: No such file or directory)
  use_frontend  | nginx: [emerg] open() &quot;/etc/nginx/nginx.conf&quot; failed (2: No such file or directory)
  </code></pre>
  <p>What exactly am I doing wrong with the Docker volume mounting?</p>