I've dockerized a node.js app and created a docker-compose file to run it along with mongo. I'm using docker for development, so for this reason I need nodemon.
Here's my Dockerfile:
FROM node:carbon-alpine
RUN mkdir -p usr/src/app
WORKDIR /usr/src/app
RUN npm install -g nodemon
COPY package*.json /usr/src/app
RUN yarn install
COPY . /usr/src/app
EXPOSE 3000
CMD [ "yarn", "start-local" ]
And here's the docker-compose
version: "3"
services:
app:
container_name: app
restart: always
build: .
volumes:
- .:/usr/src/app
environment:
- MONGO_URI=mongodb://mongo:27017/test
ports:
- "3000:3000"
depends_on:
- mongo
networks:
app_net:
mongo:
container_name: app-mongo
image: mongo:3.6.6-jessie
volumes:
- ./data:/data/db
networks:
app_net:
aliases:
- mongo
networks:
app_net:
When I run docker-compose up I get an error /bin/sh: nodemon: not found. When I run a single container without compose Everything works fine. What's wrong with the docker-compose definition?
yarn start-localwill look for nodemon in your dependencies, make sure in it's in your package.json, under dependencies or devDependencies.