Closed abasimdev closed 4 years ago
try these CMD ["java", "-jar", "${app}"] java was not found because in specified path there was not .jar file working dir was not changing because you haven't specifed the working dir was given as . which is present working dir by default
hi abasimdev, if you change the working directory please remove env arg because you are set environment variable for workdir
Following is my image code : '''
1 FROM openjdk:8 2 ARG url=https://referenceappkhaja.s3-us-west-2.amazonaws.com/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar 3 ADD ${url} . 4 ENV app=spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar 5 ENV dir=. 6 WORKDIR ${dir} 7 EXPOSE 8080 8 CMD ["java", "-jar", ${app}]
''' My image does not run and gives me the following error: "/bin/sh: 1: [java,: not found"
However, the same image runs If I change the CMD command as follows: ''' CMD java -jar ${app}
''' Even If my image runs but still I am unable to change my Workdir, to change Workdir I run it as follow: ''' docker container run -e dir=/opt -it -P spc:10 /bin/bash
''' But it always runs in the root directory!