title: Reload code inside docker container. PM2. Node js
body: <p>I try to reload my node js app code inside docker container. I use pm2 as process manager. Here is my configurations:
  <strong>Dockerfile</strong></p>
  
  <pre><code>FROM node:6.9.5
  
  LABEL maintainer "denis.ostapenko2@gmail.com"
  
  RUN mkdir -p /usr/src/koa2-app
  
  COPY . /usr/src/koa2-app
  
  WORKDIR /usr/src/koa2-app
  
  RUN npm i -g pm2
  
  RUN npm install
  
  EXPOSE 9000
  
  CMD [ "npm", "run", "production"]
  </code></pre>
  
  <p><strong>ecosystem.prod.config.json</strong> (aka pm2 config)</p>
  
  <pre><code>{
    "apps" : [
      {
        "name"        : "koa2-fp",
        "script"      : "./bin/www.js",
        "watch"       : true,
        "merge_logs"  : true,
        "log_date_format": "YYYY-MM-DD HH:mm Z",
        "env": {
          "NODE_ENV": "production",
          "PROTOCOL": "http",
          "APP_PORT": 3000
        },
        "instances": 4,
        "exec_mode"  : "cluster_mode",
        "autorestart": true
      }
    ]
  }
  </code></pre>
  
  <p><strong>docker-compose.yaml</strong></p>
  
  <pre><code>version: "3"
  services:
    web:
      build: .
      volumes:
        - ./:/koa2-app
      ports:
        - "3000:3000"
  </code></pre>
  
  <p><strong>npm run production -</strong> 
  pm2 start --attach ecosystem.prod.config.json</p>
  
  <p>I run 'docker-compose up' in the CLI and it works, I'm able to interact with my app on localhost:3000. But if make some change to code it will not show up in web. How can I configure code reloading inside docker?</p>
  
  <p>P.S. And best practices question: Is it really OK to develop using docker stuff? Or docker containers is most preferable for production use. </p>