Oleg Oleg - 7 months ago 39
Node.js Question

is it possible to run shell script and then node app.js inside docker container

i have to run some shell script which creates some certificates before the

node app.js
command is called in Dockerfile. how can i do it so it won't exit after running a shell script and will continue to run the
node app.js
web app.

Lix Lix

What I have done in the past is have my entrypoint defined in the Dockerfile be a shell script and then run the node command from within that script.

So in my Dockerfile I have this -

ENTRYPOINT ["./docker-start.sh"]

And my docker-start.sh script contains this:

#! /bin/bash

# Initialization logic can go here

echo "Starting node..."
node start.js $* # The $* allows me to pass command line arguments that were passed to the docker run command. 

# Cleanup logic can go here