Reputation: 4263
Is something like this possible to run two node.js scripts in one docker container?
docker run -d --name nt -v "$PWD":/usr/src/app -w /usr/src/app node node 2.js && node 1.js
Neither this:
docker run -d --name nt -v "$PWD":/usr/src/app -w /usr/src/app node node 2.js node 1.js
Or is this something that is not meant to be?
Upvotes: 1
Views: 815
Reputation: 36763
First, use &
instead of &&
. One &
means "send the command to background".
Second, use quotes in order to tell bash to not interpret the &
, and leave the interpretation to the shell inside the container.
Third use 'sh -c' to group the commands (optional).
Do this:
docker run -d --name nt -v "$PWD":/usr/src/app -w /usr/src/app node sh -c 'node 2.js & node 1.js'
However I recommend to use supervisor
to get a more robust solution:
https://docs.docker.com/engine/admin/multi-service_container/
Upvotes: 1