Docker run - Error: Could not find or load main class org.springframework.boot.loader.JarLauncher

Viewed 843

I had this Dockerfie perfectly running on my macbook but when I am trying to build and run it on the windows I am getting error

docker run --name my-project-container my-project:latest

Docker run  - Error: Could not find or load main class org.springframework.boot.loader.JarLauncher

I am adding my Dockerfile here

FROM openjdk:8-jre-alpine

ADD target/my-project-1.0.jar my-project-1.0.jar
ADD etc etc

EXPOSE 8080:8080

ENTRYPOINT ["java", "-jar", "my-project-1.0.jar"]

Which while building gives warning

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

Docker run  - Error: Could not find or load main class org.springframework.boot.loader.JarLauncher

I have even tried to add the jar containing the org.springframework.boot.loader.JarLauncher class but in vain. Also since I was perfectly able to run this same on my macbook, I am sure there is more to the error than that class org.springframework.boot.loader.JarLauncher

1 Answers

maybe try add below dependency?

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
<version>2.3.12.RELEASE</version>
</dependency>
Related