我正在尝试将我的快速应用程序停靠,但是当我尝试在容器中运行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
答案 0 :(得分:-1)
在Dockerfile
的某处,投入RUN npm install nodemon -g
。这会安装并添加到您的路径