Wednesday, 17 May 2017

How come that `docker-compose up` throws an error where `docker run` works fluently

I'm trying to set-up an environment for development & production of an NodeJS application with Docker. For the development environment I try to run the application with nodemon (since this watches for file changes). But when I try to run it with docker-compose up, I get the following error:

ERROR: for web Cannot start service web: oci runtime error: container_linux.go:247: starting container process caused "exec: \"nodemon\": executable file not found in $PATH"

When I run docker run web-app (the web-app image is generated with docker build -t web-app . I have no problems at all. I would like to know how this different behavior occurs, and how to resolve it. Below I've put the files I've got for simpler understanding of the problem.


Dockerfile

FROM node:latest

# Install nodemon globally
RUN npm i nodemon -g

# Add local directory to /node/web-app
ADD . /node/web-app
# Switch to /node/web-app
WORKDIR /node/web-app

# Install NPM dependencies
RUN npm install

# Run nodemon
CMD ["nodemon", "."]


docker-compose.yml

version: '2'
services:   
web:
    build:
      context: .
      dockerfile: Dockerfile



via user007

No comments:

Post a Comment