Docker compose not finding my index.js

I’m following this guide and use my low docker knowledge to get a dev environment up and running. I’ve hit a wall I cannot solve. This is my docker-compose.yml:

version: '2'
    image: redis:3.2
    image: mongo:3.2
    build: .
      - '3000:3000'
    command: './node_modules/.bin/nodemon ./index.js'
      NODE_ENV: development
      - .:/home/app/cardcreator
      - /home/app/cardcreator/node_modules
      - redis
      - mongo
      - redis
      - mongo

and this is my Dockerfile:

  • docker container ipv6 configuration not working
  • How to create mysql volume which exists even if i remove the docker container
  • distributed wide and deep with tf.contrib.learn api example stuck on k8s
  • Updating docker images with small changes using commits
  • How to register EC2 Instance to ECS cluster?
  • Percona 5.6 Docker Image cannot load my /etc/mysql/conf.d/*.cnf
  • FROM node:6.3.1
    RUN useradd --user-group --create-home --shell /bin/false app
    ENV HOME=/home/app
    COPY package.json npm-shrinkwrap.json $HOME/cardcreator/
    RUN chown -R app:app $HOME/*
    USER app
    WORKDIR $HOME/cardcreator
    RUN npm install
    USER root
    COPY . $HOME/cardcreator/
    RUN chown -R app:app $HOME/*
    USER app
    CMD ["node", "index.js"]

    When I try to start the app via docker-compose up, I get the error

    app_1    |   Usage: nodemon [nodemon options] [script.js] [args]
    app_1    |   See "nodemon --help" for more.

    I then removed the command line of my docker-compose.yml, only leaving node index.js to start. I get an error saying index.js cannot be found.

    The file is in my project folder, it is there and it has content. I can’t figure out why this setup doesn’t work, I did similar setups for tails and it worked fine.

    Can anyone tell me what I’m doing wrong here?

  • docker tomcat directory not found?
  • docker: Couldn't connect to Docker daemon
  • How to correctly install RVM in Docker?
  • Docker Compose does not bind ports
  • Docker Compose for Rails
  • How to make Docker to avoid V1 registry
  • 2 Solutions collect form web for “Docker compose not finding my index.js”

    Whatever you are mounting in your compose file here:

    - .:/home/app/cardcreator

    Is going to mount on top of whatever you built in $HOME/cardcreator/ in your Dockerfile.

    So basically you seem to have conflicting volumes — it’s an order of operations issue — the build is going to happen first and the volume mount happens later when the container runs, so your container will no longer have access to the files built in the Dockerfile.

    You could try to use

    docker exec -it app_1 bash

    to go into the container, trying to execute the

    node index.js 

    command manually and see what’s going on. Not 100% sure if the ‘node’ docker images have bash installed though..

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.