skip to Main Content

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

2

Answers


  1. 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 Dockerfile, try to change add to ADD, as it seems your target files are not been copied into the image built.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search