How to run shell scripts along with java applications using docker?

Following is my Dockerfile , i am copying a folder and two java jar files onto the image and the intention was to execute the script file which is inside the copied directory followed by executing the two java applications .

FROM openjdk:latest
COPY ./mycluster /dir/latest/
COPY ./app1.jar /dir/latest/
COPY ./app2.jar /dir/latest/ 
CMD ["sh", "-c", "cd /dir/latest/ ;./local_cluster_startup.sh ./;sleep 5 ;java -jar app2.jar;sleep 5;java -jar app1.jar;"]

After building the docker image and running the following command docker container run tryout:nsdap the output is

sh: 1: cd: can't cd to /dir/latest/
sh: 1: ./local_cluster_startup.sh: not found
Error: Unable to access jarfile app2.jar
Error: Unable to access jarfile app1.jar

Can anyone please tell me what am doing wrong here ?

I am looking for a minimal docker image that would be able to execute java jars and the shell scripts . Can you please help me out ? Thanks

1 answer