Unable to Launch Node.js Application Inside Built Docker Container

I’ve built a docker container (node.js installed along with some project files) with the following Dockerfile:

RUN yum install -y openssl wget unzip gcc gcc-c++ tar make automake git
RUN curl -L https://www.opscode.com/chef/install.sh | bash

[... Chef Related Stuff ...]

#Docker CMD
WORKDIR /var/node
CMD ["/usr/bin/node /var/node/lib/app.js"]

The container it builds is designed to use a shared directory with the local machine on which docker is being used. When I attempt to launch the built container (i.e. the one containing the CMD ["/usr/bin/node /var/node/lib/app.js"] portion) I find that the container is unable to launch:

  • Can you use nginx reverse proxy to docker containers without exposing any ports?
  • Automate iOS application with Appium in Docker
  • Dockerfile versioning best practice
  • Setting up ReactJS in windows 10 giving error
  • Looking for a Docker image that automatically detects the application language
  • Run IIS Windows container
  • US-C02NC26AG3QN:docker user$ docker run -d -v /Users/user/Documents/test_area/docker/nodejs:/var/node front/nodejs
    db07b901e83fb45f19d00151129ce42b836cf2379d91cebea54de8b51add614b
    2014/11/04 10:42:56 Error response from daemon: Cannot start container db07b901e83fb45f19d00151129ce42b836cf2379d91cebea54de8b51add614b: exec: "/usr/bin/node /var/node/lib/app.js": stat /usr/bin/node /var/node/lib/app.js: no such file or directory
    

    However, if I omit the the CMD ["/usr/bin/node /var/node/lib/app.js"] section from the Dockerfile, rebuild the image, and launch the container in the typical way it works just fine:

    US-C02NC26AG3QN:docker user$ docker run -d -v /Users/user/Documents/test_area/docker/nodejs:/var/node front/nodejs /usr/bin/node /var/node/lib/app.js
    ab83f476bde812f179c461eacb954fc59da4bcc9e22f5b14fd71d257cd7ade40
    US-C02NC26AG3QN:docker user$ docker ps
    CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS              PORTS               NAMES
    ab83f476bde8        front/nodejs:latest   "/usr/bin/node /var/   4 days ago          Up 3 seconds                            clever_lovelace
    US-C02NC26AG3QN:docker user$ docker top ab83f476bde8
    PID                 USER                COMMAND
    19815               root                /usr/bin/node /var/node/lib/app.js
    

    What is happening here? Why is it not able to fine the directory when the launch command is included in the build but able to find the directory when the launch command is used explicitly when starting the container?

  • Running apache in an ubuntu Docker container on a RedHat machine
  • crash error when execute docker-compose
  • Docker containers seem to 'inherit' the instance profile of the host ec2. How?
  • Postgres docker-image won't run and won't start [closed]
  • Docker compose error with docker-engine version
  • Ansible error due to GMP package version on Centos6
  • One Solution collect form web for “Unable to Launch Node.js Application Inside Built Docker Container”

    CMD with brackets implies you’re giving all the arguments as a list. So you’d need to do

    CMD ["node", "app.js"]
    

    You can also run it with bash as

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