-1

I downloaded a vert.x starter project from http://start.vertx.io/ and would like to run the compiled binary with java -jar .. inside a Docker container.

Current invocation command:

mvn package exec:java -DskipTests

Current Dockerfile:

FROM java:10
COPY target/project-1.0-SNAPSHOT.jar project.jar
ENTRYPOINT java -jar project.jar

which gives the following error message when run

no main manifest attribute, in /project/target/vertx-start-project-1.0-SNAPSHOT.jar

Is there a simpler way than building a full deployment assembly as is usually done with Maven?

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

3 Answers3

2

When you run a command like so:

mvn package exec:java

The vert.x specfic configuration will make Maven create:

SNAPSHOT.jar
SNAPSHOT-fat.jar

like so:

enter image description here

the fat.jar has all the files in it, so you only need to copy that jar file to the Docker image.

FROM openjdk:10-jre-slim
COPY target/SNAPSHOT-fat.jar fat.jar
ENTRYPOINT java -jar fat.jar

you build the docker image with:

docker build -t foo .

then run the docker image as a container with:

docker run -it foo
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0

A runnable jar requires a Main-Class entry in MANIFEST.MF with the name of the class to launch.

You will most likely also need your dependencies copied in.

Consider this a full deployment of your application.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

Like what Thorbjørn said, this command executes a "runnable" jar, which means it should have packed with a MANIFEST.MF that points to some certian main method in your project

Ahmad Khundaqji
  • 332
  • 2
  • 12