Skip to content
Advertisement

No Main Class found when running a dockerizing image

I have a university project which consist of building a Java Spring Boot application that can handle multiple APIs that can start new docker containers running jar applications.

For the moment, I was able to experiment how Spring Boot works, so I built a simple jar to deploy a simple greeting API that returns “Hello World!”

So I have built and pushed a docker image using jib-core to my DockerHub repo which work fine.

JavaScript

The problem is, when I execute the following command docker run -i -t dmh911/localkube:latest, I get in return this error:

JavaScript

This is the jar MANIFEST file:

JavaScript

I know that the problem is probably something very silly, but I don’t know what exactly.

Advertisement

Answer

What you’re code will execute is java demo-0.0.1-SNAPSHOT.jar, which will try to run the class demo-0.0.1-SNAPSHOT.jar, which is unlikely to exist because this is probably the name of your jar file, and not the class you want to run.

Instead your entrypoint should be java -jar demo-0.0.1-SNAPSHOT.jar, which means you need to change your code to .setEntrypoint("java", "-jar", "demo-0.0.1-SNAPSHOT.jar").

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement