Я новичок в докере.Я попытался докернизировать мое существующее приложение узла.Во время docker-compose приложение выдает ошибку о том, что не может найти node_modules.
Вот ошибка
dockerised-yelpcamp | > dockerised-yelpcamp@1.0.1 start /usr/src/app
dockerised-yelpcamp | > node app.js
dockerised-yelpcamp |
dockerised-yelpcamp | internal/modules/cjs/loader.js:584
dockerised-yelpcamp | throw err;
dockerised-yelpcamp | ^
dockerised-yelpcamp |
dockerised-yelpcamp | Error: Cannot find module 'express'
dockerised-yelpcamp | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
dockerised-yelpcamp | at Function.Module._load (internal/modules/cjs/loader.js:508:25)
dockerised-yelpcamp | at Module.require (internal/modules/cjs/loader.js:637:17)
dockerised-yelpcamp | at require (internal/modules/cjs/helpers.js:22:18)
dockerised-yelpcamp | at Object.<anonymous> (/usr/src/app/app.js:1:77)
.
.
.
dockerised-yelpcamp | at Function.Module._load (internal/modules/cjs/loader.js:531:3)
dockerised-yelpcamp | npm ERR! code ELIFECYCLE
dockerised-yelpcamp | npm ERR! errno 1
dockerised-yelpcamp | npm ERR! dockerised-yelpcamp@1.0.1 start: `node app.js`
dockerised-yelpcamp | npm ERR! Exit status 1
dockerised-yelpcamp | npm ERR!
dockerised-yelpcamp | npm ERR! Failed at the dockerised-yelpcamp@1.0.1 start script.
dockerised-yelpcamp | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
dockerised-yelpcamp | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
dockerised-yelpcamp |
dockerised-yelpcamp | npm ERR! A complete log of this run can be found in:
dockerised-yelpcamp | npm ERR! /root/.npm/_logs/2019-04-17T11_14_17_109Z-debug.log
dockerised-yelpcamp exited with code 1
docker-compose.yml
version: "3"
services:
main_app:
container_name: dockerised-yelpcamp
restart: always
build: .
ports:
- 80:3000
links:
- mongo
volumes: ["./:/usr/src/app"]
mongo:
container_name: mongo
image: mongo
ports:
- 27017:27017
Dockerfile
FROM node:10
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
Мой файл Docker содержит npm install
, который успешно выполняется при построении образа.