question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to package Spring Boot Executable Jar to Docker image?

See original GitHub issue

Spring Boot Gradle and Maven plugins produce single Executable Jar file as described in reference docs https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#getting-started-first-application-executable-jar https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#executable-jar

It would be nice if jib supports this, pack just a single file into the image and use -jar, /app/libs/app.jar option instead of -cp, /app/resources/:/app/classes/:/app/libs/*, app.Main.

How to package Spring Boot Executable Jar to Docker image? Maybe it can be possible to achieve the same effect through some jib settings?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AlekseyChudovcommented, Sep 7, 2018

It’s too easy. I should have guessed 😃

Also dependencies should be added to make tasks work

jibBuildTar.dependsOn bootJar
jibDockerBuild.dependsOn bootJar
jibExportDockerContext.dependsOn bootJar
1reaction
coollogcommented, May 7, 2019

@AlekseyChudov You can configure command line options via the jib.container.jvmFlags parameter.

To use the JAR itself, you can set some configuration options to have Jib copy the JAR into the container:

build.gradle:

jib {
    extraDirectories.paths = bootJar.destinationDir
    container.entrypoint = ['java', '-jar', bootJar.archiveName]
}

Note(by @loosebazooka): We definitely do not recommend using Jib this way, but it will work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started | Spring Boot with Docker
The build creates a spring user and a spring group to run the application. It is then copied (by the COPY command) the...
Read more >
Dockerizing a Spring Boot Application - Baeldung
In this tutorial, we'll focus on how to dockerize a Spring Boot Application to run it in an isolated environment, a.k.a. container.
Read more >
9 Tips for Containerizing Your Spring Boot Code - Docker
Containerizing a Spring Boot application is easy. You can do this by copying the .jar or .war file right into a JDK base...
Read more >
Docker Basics and Easy Steps to Dockerize Spring Boot ...
Create a Spring Boot Application · Create Dockerfile · Build executable jar file · Build Docker image · Run Docker container using the...
Read more >
How To Dockerize a Spring Boot Application - HowToDoInJava
2. Verify the Docker Installation · Create a Spring Boot Application · Create an Executable JAR file · Create a Dokerfile · Create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found