My web app uses Node.js and MongoDB. I am pulling mongo image from docker image hub. When I build an image of my node app it runs fine alone. However when I start up containers using compose it gives the following error. Isn't it supposed to install the packages when image is built from Dockerfile?
web_1 | module.js:457 web_1 | throw err;
web_1 | ^
web_1 |
web_1 | Error: Cannot find module 'mongoose'
web_1 | at Function.Module._resolveFilename (module.js:455:15)
web_1 | at Function.Module._load (module.js:403:25)
web_1 | at Module.require (module.js:483:17)
web_1 | at require (internal/module.js:20:19)
web_1 | at Object. (/worklog/worklog.js:7:14)
web_1 | at Module._compile (module.js:556:32)
web_1 | at Object.Module._extensions..js (module.js:565:10)
web_1 | at Module.load (module.js:473:32)
web_1 | at tryModuleLoad (module.js:432:12)
web_1 | at Function.Module._load (module.js:424:3)
Dockerfile
FROM node
RUN mkdir -p /worklog
WORKDIR /worklog
RUN npm install mongoose \
express \
body-parser \
express-session \
method-override \
connect-mongo \
mongodb
COPY login.html worklog.html workloglist.html worklog.js /worklog/
ENV NODE_VERSION 6.3.1
EXPOSE 4000
CMD npm, start
docker-compose.yml
db:
image: mongo
ports:
- "27017:27017"
command: "--smallfiles --logpath=/dev/null"
web:
build: .
command: node worklog.js
volumes:
- .:/worklog
ports:
- "4000:4000"
links:
- db
environment:
PORT: 4000
docker-compose upor your command. Yes I can see db_1 running. - emre01