未找到模块(nodemon)(未找到package.json)DOCKER ISSUE

时间:2018-05-20 19:28:50

标签: express docker nodemon

我正在尝试将我的快速应用程序停靠,但是当我尝试在容器中运行CMD时,docker说我''Command \“nodemon \”找不到。“'就像它找不到package.json在容器中。这是我的dockerfile:

FROM node:8
WORKDIR /express-app/

COPY package.json .

RUN yarn

COPY . .

ARG MONGO_DB_DATABASE
ENV MONGO_DB_DATABASE ${MONGO_DB_DATABASE}
ARG MONGO_DB_USERNAME
ENV MONGO_DB_USERNAME ${MONGO_DB_USERNAME}
ARG MONGO_DB_PASSWORD
ENV MONGO_DB_PASSWORD ${MONGO_DB_PASSWORD}

EXPOSE 3000

CMD ["yarn", "start"]

这是我的docker-compose.yml

express-app:
build: ../../express-app
command:nodemon
environment:
  - MONGO_DB_DATABASE=testDb
  - MONGO_DB_USERNAME=test
  - MONGO_DB_PASSWORD=test
expose:
  - 3000
ports:
  - "3000:3000"
volumes:
  - ../../express-app:/express-app
depends_on:
  - mongodb
links:
  - mongodb
restart: always

1 个答案:

答案 0 :(得分:-1)

Dockerfile的某处,投入RUN npm install nodemon -g。这会安装并添加到您的路径