Home > Enterprise >  My spring boot application was running fine but when I dockerized it I got File not Found error
My spring boot application was running fine but when I dockerized it I got File not Found error

Time:08-21

I don't know what I'm getting this error when I dockerized my spring-boot application

this is my Dockerfile enter image description here

CodePudding user response:

In your spring boot application, from what I can see your BookingController is missing.

Make sure you have the file present and build your image accordingly.

For your Docker file try to change "add" to "ADD" .

It seems your target files are not been copied into the image built.

CodePudding user response:

First, I wonder is your application working on your IDE?

Second, I think you make sure to build and package. It is not sure to exists a jar file in your target folder. You always have to build and check by yourself.

Make the build process automatic.

How about using this Dockerfile?

FROM maven:3.8.6-openjdk-18-slim as MAVEN_BUILD

WORKDIR /build

COPY pom.xml .

RUN mvn dependency:go-offline

COPY src ./src

RUN mvn package -Dmaven.test.skip=true

FROM openjdk:18-alpine

WORKDIR /app

ARG JAR_FILE=*.jar

COPY --from=MAVEN_BUILD /build/target/${JAR_FILE} ./app.jar

EXPOSE 8080

CMD ["java", "-jar", "app.jar"]

If maven or openjdk version not matched, check this site.

  • Related