title: Docker-compose: node_modules not present in a volume after npm install succeeds
body: <p>I have an app with the following services:</p>
  
  <ul>
  <li><code>web/</code> - holds and runs a python 3 flask web server on port 5000. Uses sqlite3.</li>
  <li><code>worker/</code> - has an <code>index.js</code> file which is a worker for a queue. the web server interacts with this queue using a json API over port <code>9730</code>. The worker uses redis for storage. The worker also stores data locally in the folder <code>worker/images/</code></li>
  </ul>
  
  <p>Now this question only concerns the <code>worker</code>.</p>
  
  <h3><code>worker/Dockerfile</code></h3>
  
  <pre><code>FROM node:0.12
  
  WORKDIR /worker
  
  COPY package.json /worker/
  RUN npm install
  
  COPY . /worker/
  </code></pre>
  
  <h3><code>docker-compose.yml</code></h3>
  
  <pre><code>redis:
      image: redis
  worker:
      build: ./worker
      command: npm start
      ports:
          - "9730:9730"
      volumes:
          - worker/:/worker/
      links:
          - redis
  </code></pre>
  
  <p>When I run <code>docker-compose build</code>, everything works as expected and all npm modules are installed in <code>/worker/node_modules</code> as I'd expect.</p>
  
  <pre><code>npm WARN package.json unfold@1.0.0 No README data
  
  &gt; phantomjs@1.9.2-6 install /worker/node_modules/pageres/node_modules/screenshot-stream/node_modules/phantom-bridge/node_modules/phantomjs
  &gt; node install.js
  
  &lt;snip&gt;
  </code></pre>
  
  <p>But when I do <code>docker-compose up</code>, I see this error:</p>
  
  <pre><code>worker_1 | Error: Cannot find module 'async'
  worker_1 |     at Function.Module._resolveFilename (module.js:336:15)
  worker_1 |     at Function.Module._load (module.js:278:25)
  worker_1 |     at Module.require (module.js:365:17)
  worker_1 |     at require (module.js:384:17)
  worker_1 |     at Object.&lt;anonymous&gt; (/worker/index.js:1:75)
  worker_1 |     at Module._compile (module.js:460:26)
  worker_1 |     at Object.Module._extensions..js (module.js:478:10)
  worker_1 |     at Module.load (module.js:355:32)
  worker_1 |     at Function.Module._load (module.js:310:12)
  worker_1 |     at Function.Module.runMain (module.js:501:10)
  </code></pre>
  
  <p>Turns out none of the modules are present in <code>/worker/node_modules</code> (on host or in the container). </p>
  
  <p>If on the host, I <code>npm install</code>, then everything works just fine. But I don't want to do that. I want the container to handle dependencies.</p>
  
  <p>What's going wrong here?</p>
  
  <p>(Needless to say, all packages are in <code>package.json</code>.)</p>