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:

  • Boot2docker very slow on Windows without shared folders
  • docker restart,exit command, reboot the host machine
  • Docker mac symfony 3 very slow
  • Rancher: Unsupported config option for xxx service: 'upgrade_strategy'"
  • How to deploy app in this meteor docker image?
  • How can I create a stream for DockerDotNet BuildImageFromDockerfile method?
  • US-C02NC26AG3QN:docker user$ docker run -d -v /Users/user/Documents/test_area/docker/nodejs:/var/node front/nodejs
    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
    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?

  • Why pulling private image in Pod is not working in Kubernetes Registry addon?
  • Share and update docker data containers across containers
  • Supervisord does not show stdout from processes
  • ImportError: No module named ssl_match_hostname when importing the docker SDK for Python
  • Tag latest not found in repository docker.io/library/<package>
  • Kubernetes - how to send request to all the minions?
  • 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.