I have base docker image where I have a Dockerfile which has an entry like follows
CMD ["/bootstrap.sh"]
In my child docker image where I am referencing this parent docker image, I have a separate entrypoint which starts my container as java program like below
ENTRYPOINT exec java -Duser.timezone=GMT -Djava.security.egd=file:/dev/./urandom $JAVA_OPTS -jar /app.jar
When I build this child docker image and try to run it, only the java program is coming up. bootstrap,sh is not building up.
After going through some blogs and stackoverflow posts, I cam to know in the child image, CMD context from parent image is lost and overwritten by child image entrypoint. However, I would like to run both shell script as well as java program on entrypoint. In my shell script, I jhave few executables reference which I require it to run and they will keep running the shell programs in background which my Java code will call to and do the processing based on these shell programs.
I also did try to combine both of these steps into one entrypoint like below but then this is only starting up one process - either shell script or Java program depending on which is specified first in dockerfile
ENTRYPOINT /bootstrap.sh && exec java -Duser.timezone=GMT -Djava.security.egd=file:/dev/./urandom $JAVA_OPTS -jar /app.jar
How can I specify in Dockerfile so that it can execute both the processes on startup of the container. bootstrap.sh can be run in background also.
Please help me on this one.
CMD java ..., which will make it easy to run a second container with an alternate commanddocker run ... the-image /bootstrap.sh. - David Mazejavaprogram on the one hand, and your services launched bybootstrap.shshould be in two different containers. BTW, note that anENTRYPOINTcommand should always be in exec form (i.e., with["…", "…"]), otherwise theCMDspec is ignored (even if you specifyCMDafterENTRYPOINT). For details, see that other SO thread CMD doesn't run after ENTRYPOINT in Dockerfile. - ErikMD