docker – image not updating after building

  docker, docker-compose, node.js

After I run docker-compose up -d --build, I run docker images, it shows:

REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
test-tets-test-server_my-web                  latest              2a3f05e387a7        1 minutes ago       2.81GB

But When I run docker run -it 2a3f05e387a7 sh and look for the files, it seems that the files are not updating and still in old version.

Dockerfile

FROM node:lts-alpine

RUN npm install --global sequelize-cli nodemon

WORKDIR /server

COPY package*.json ./

RUN npm install

COPY . . 

EXPOSE 3030

CMD ["npm", "run", "dev"]

docker-compose.yml

version: '2.1'

services:
  test-db:
    image: mysql:5.7
    ...
  test-web:
    environment:
      - NODE_ENV=local
      - PORT=3030
    build: .           
    command: >
      ./wait-for-db-redis.sh test-db npm run dev
    volumes:
      - ./:/server     
    ports:
      - "3030:3030"
    depends_on:
      - test-db

package.json

...
  "scripts": {
    "test": "npm run lint && npm run mocha",
    "lint": "eslint src/. test/. --config .eslintrc.json --fix",
    "dev": "nodemon --legacy-watch src/",
    "start": "node src/",
  },
...

Source: Docker Questions

LEAVE A COMMENT