I have the following nodejs dockerfile:
# pull image
FROM node:13.12.0-alpine
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install
# add app
COPY . ./
# start app
CMD node server dev
I need to dynamically run a custom JS script inside the container after start up. How can I achieve this?
UPDATE: I tried adding the following entry point after CMD, but neither CMD not ENTRYPOINT was executed:
ENTRYPOINT node customScript.js
Added a wrapper shell script (startup.sh) to include both commands:
#!/bin/sh
nohup node server dev > startup.log && node data/scripts/custom.js > custom.log
Replaced CMD with:
CMD ["./startup.sh"]
This only executes the first command in the shell and not the second. I also don't see the output-redirect log files being created in the container.



docker run the-same-image some other command(if you do not useENTRYPOINT).