Reputation: 634
So, I have a spring boot application, and it in part takes in a file and reads the contents. It runs perfectly locally, but when I put it on a Docker image and deploy to azure, I get a file not found error. Here is my dockerfile:
FROM [place]
VOLUME /tmp
ARG jarFileName
RUN mkdir /app
COPY $jarFileName /app/app.jar
RUN sh -c 'touch /app/app.jar'
ENV JAVA_OPTS=""
COPY startup.sh /app/startup.sh
RUN ["chmod", "+x", "/app/startup.sh"]
CMD ["startup.sh"]
Upvotes: 0
Views: 124
Reputation: 31384
With the Dockerfile you posted, I think there are several places need to pay attention to.
The first is that the line COPY $jarFileName /app/app.jar
will get the error if you do not pass the variable jarFileName in the command docker run
.
The second is that you should check the current directory for the line COPY startup.sh /app/startup.sh
if there is the file startup.sh.
The last is that the line CMD ["startup.sh"]
, I think you should change it into CMD ["./startup.sh"]
. Usually, we execute a shell script using the command sh script.sh
or ./script.sh
if the script has the permission 'x'.
Upvotes: 1