Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 846
Oleg Avatar asked Nov 17 '25 15:11

Oleg


1 Answers

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
like image 69
Lix Avatar answered Nov 20 '25 13:11

Lix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!