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:

  • Create a nodejs container Docker based on ubuntu
  • Docker port expose
  • Connection refused while launching docker containers using java client
  • How do I deploy to a remote docker host on windows server 2016?
  • Can't start docker
  • how to use Openvswitch bridge as bridge driver in docker libnetwork
  • 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?

  • docker jenkins dsl pipeline
  • Is there a way to simulate docker to have physical interfaces?
  • Get all containers/images using docker-java client library [closed]
  • NoHostAvailableException in DBeaver when connecting to remote Cassandra docker container
  • Error checking TLS connection: Error checking and/or regenerating the certs
  • Connecting to SQL Server Express from within Docker Container gives an error occurred evaluating the password
  • 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.