0

Concurrently allows me to run client and server simultaneously within the same terminal and the command for it is npm run dev from my server folder.

I am trying to avoid creating multiple Dockerfiles for client and server folder.

After building and image of my whole project, is it possible to use docker run [image] to call on CMD or ENTRYPOINT [npm run dev] to replicate the same behaviour as starting my application outside of docker? How would i format my DockerFile to go into server folder and runnpm run dev to load up client and server?

i gave my code a try and apparently the error i get back is docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "npm run dev": executable file not found in $PATH: unknown.

enter image description here

enter image description here

1 Answer 1

0

Your problem is that you are using the exec form of ENTRYPOINT/CMD:

Command line arguments to docker run will be appended after all elements in an exec form ENTRYPOINT, and will override all elements specified using CMD. This allows arguments to be passed to the entry point, i.e., docker run -d will pass the -d argument to the entry point. You can override the ENTRYPOINT instruction using the docker run --entrypoint flag.

The shell form prevents any CMD or run command line arguments from being used, but has the disadvantage that your ENTRYPOINT will be started as a subcommand of /bin/sh -c, which does not pass signals. This means that the executable will not be the container’s PID 1 - and will not receive Unix signals - so your executable will not receive a SIGTERM from docker stop .

To run num run dev on our container, you should use either

ENTRYPOINT ["npm", "run", "dev"] # using the exec form correctly

or

ENTRYPOINT npm run dev # using the shell form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.