EDITED - Added folder structure
I'm trying to run a node.js app in a docker container using docker-compose, however, the container fails to run the specified command and exits.
I'm running docker-for-mac, version 17.09.0-ce-mac35 (19611)
This is my folder structure:
.
├── docker-compose.yml
├── backend/
│ ├── Dockerfile
│ ├── package.json
│ ├── (source files)
├── frontend/
│ ├── Dockerfile
│ ├── package.json
│ ├── (source files)
This is my docker-compose file:
version: "3"
services:
ihm-backend:
environment:
- NODE_ENV=development
build: ./backend
volumes:
- ./backend:/src
ports:
- "3000:3000"
- "9222:9222"
working_dir: /src
command:
- "./node_modules/.bin/nodemon --watch ./ --inspect=0.0.0.0:9222 --nolazy ./app.js"
And this is my Dockerfile:
FROM node:6-alpine
COPY ./package.json src/
COPY ./npm-shrinkwrap.json src/
RUN cd /src && npm install
COPY . /src
WORKDIR /src
CMD ["./bin/www"]
Notice that the docker-compose file overrides the command.
When I run it, I get the following error:
Cannot start service ihm-backend: oci runtime error: container_linux.go:265:
starting container process caused "exec: \"./node_modules/.bin/nodemon --watch
./ --inspect=0.0.0.0:9222 --nolazy ./app.js\": stat ./node_modules/.bin/nodemon
--watch ./ --inspect=0.0.0.0:9222 --nolazy ./app.js: no such file or directory"
I tried to play with the command a bit - when changing it to ls or pwd I got the expected output. However, once I try to use npm or anything from the file-system like ls ./node_modules, I get the same error. Also, if I just start the container into a shell, I'm able to run any command I want, including npm scripts
package.jsonand is it installed on docker image?