title: Docker container with webpack and volume does not save files into host from container volume. Just empty folders
body: <p>I have docker-compose file for serving several containers.</p>
  
  <p>Main idea: build frontend app via webpack and then through volumes grant access to built files to nginx container. Unfrotunately, I tried many things (stumbled upon my missing knowledge about that volumes are attached when container is starting but not building) and my current setup looks like this:</p>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '2'
  services:
    nginx:
      build:
        context: .
        dockerfile: nginx.dockerfile
      ports:
        - '10040:80'
      depends_on:
        - app
      volumes:
          - './docker/app/src:/app/src'
          - './docker/app/dist:/app/dist'
          - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
    app:
      build:
        context: .
        dockerfile: ./app.dockerfile
      entrypoint: ./app-build-dev.sh
      volumes:
          - './docker/app/src:/app/src/:rw'
          - './docker/app/dist:/app/dist/:rw'
          - './docker/app/node_modules:/app/node_modules/:rw'
  </code></pre>
  
  <p>Here is dockerfile for app.dockerfile</p>
  
  <pre><code>FROM "node"
  
  COPY . /build-dir
  
  WORKDIR /build-dir
  
  RUN rm -rf node_modules
  RUN rm -rf dist
  </code></pre>
  
  <p>Here is my script for webpack container (app-build-dev.sh):</p>
  
  <pre><code>#!/bin/sh
  
  cd /build-dir
  
  
  # echo "CHECKING INNARDS OF /app/src"
  # ls -la /app/src
  
  # echo "CHECKING INNARDS OF /app/src/js/app"
  # ls -la /app/src/js/app
  
  npm i
  npm run build-dev
  
  echo "CHECKING INNARDS OF /build-dir"
  ls -la /build-dir
  
  echo "CHECKING INNARDS OF /build-dir/src"
  ls -la /build-dir/src
  
  echo "CHECKING INNARDS OF /build-dir/dist"
  ls -la /build-dir/dist
  
  # echo "Checking index.html built"
  # cat /build-dir/dist/index.html
  
  echo "Copying everything into /app so it can be shared with nginx"
  cp -R /build-dir/* /app/*
  
  echo "CHECKING INNARDS OF /app/src"
  ls -la /app/src
  
  echo "CHECKING INNARDS OF /app/dist"
  ls -la /app/dist
  
  echo "Done"
  </code></pre>
  
  <p>As you can see I tried somehow to trick volumes since if I would work directly in the volumes (in /app in the container) - webpack would not even find needed files and save corrupted one file for index.html with message that there is no such file. But that's kinda offtop.</p>
  
  <p>Anyway, I build inside /build-dir and then copy to mounted volume folder inside container, so it would be mirrored to host machine (and then can be used by nginx container).</p>
  
  <p>What I get from that .sh script. Everything is fine except /app/dist dir is empty in container (/src is copied kind fine)</p>
  
  <p>And on my host machine I have all the mounted folders but... empty. Nothing. Files are just not there.</p>
  
  <p>Am I missing general conception here?</p>
  
  <p>Thanks!</p>