title: Why is it that when I install a new npm package I have to run "docker-compose down" followed by "docker-compose up --build"?
body: <p>Shouldn't <code>docker-compose up --build</code> suffice?</p>
  
  <p>Here's our Dockerfile:</p>
  
  <pre><code>FROM node:8.12.0-alpine
  
  # Set app directory
  WORKDIR /usr/src/app
  
  # Install git in order to allow installing
  # npm packages from Github
  RUN set -xe \
      &amp;&amp; apk add --no-cache git
  
  # Install app dependencies
  # A wildcard is used to ensure both package.json AND package-lock.json are copied
  # where available (npm@5+)
  COPY package*.json ./
  
  RUN npm install
  
  # Bundle app source
  COPY . .
  
  ENV NODE_ENV development
  
  EXPOSE 8080
  
  CMD ["npm","start"]
  </code></pre>
  
  <p>And our docker-compose file:</p>
  
  <pre><code>version: '3'
  services:
  
    web:
      build: .
      ports:
        - 8080:8080
      environment:
        MONGODB_URI: mongodb://admin:app@mongo:27017/app?authSource=admin
      volumes:
        - .:/usr/src/app
        # More info on the node_modules volume at:
        # http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html
        # under "The node_modules Volume Trick"
        - /usr/src/app/node_modules
      # Run nodemon with legacy watch
      # https://github.com/remy/nodemon#application-isnt-restarting
      # Ignore public/ because generating documentation programatically
      # on startup was causing an infinite loop
      command: ./node_modules/.bin/nodemon --legacy-watch --inspect=0.0.0.0:5858 --ignore public/
      depends_on:
        - mongo
  
    mongo:
      image: mongo:4.0
      restart: always
      environment:
        MONGO_INITDB_ROOT_USERNAME: admin
        MONGO_INITDB_ROOT_PASSWORD: app
      volumes:
        # Using a named volume because windows doesn't deal well with mounting local folders
        - app-api-mongodb-storage:/data/db
  
    mongo-express:
      image: mongo-express
      restart: always
      ports:
        - 8081:8081
      environment:
        ME_CONFIG_MONGODB_ADMINUSERNAME: admin
        ME_CONFIG_MONGODB_ADMINPASSWORD: app
      depends_on:
        - mongo
  
  volumes:
    # Database named module has to be declared globally
    app-api-mongodb-storage:
  </code></pre>
  
  <p>From what I can tell, <code>docker-compose down</code> should delete the node_modules volume, because it is created by <code>docker-compose up</code>.</p>
  
  <p>Is there some kind of caching that is preventing package.json from being refreshed unless <code>docker-compose --build</code> is used in order to explicitly rebuild the Docker image?</p>