Comments (9)
Ohhh I found the solution. You can read this tutorial: https://g00glen00b.be/docker-spring-boot/. The problem is your application load the application.properties.
You need to change the ENTRYPOINT to load the profile with the container configuration (application.yml). E.g "-Dspring.profiles.active=container"
spring:
profiles: container
jpa:
database: MYSQL
hibernate:
ddl-auto: validate
datasource:
url: jdbc:mysql://mysql:3306/tsbacked
username: root
password: 12345
driver-class-name: com.mysql.jdbc.Driver
from gs-spring-boot-docker.
It's happened the same to me. I tried to use the --link docker parameter when running my app but continue not working. Do you already found any solution? Thanks
from gs-spring-boot-docker.
thanks
from gs-spring-boot-docker.
docker run -p 8080:8080 -t 770727c11311
Error: Invalid or corrupt jarfile /app.jar
I am using the following sample app to make my own docker image
https://github.com/spring-guides/gs-spring-boot-docker.git
docker image builds successfully. and working fine with my laptop with docker terminal for windows 10.
but the same image pushed to gitlab docker registry. and using my VPS Centos server. it is getting the same error. Please help me. Or even pulling to same docker image to docker terminal for windows 10. getting the same error.
from gs-spring-boot-docker.
Could be a lot of problems...you can find many problem related to "INVALID OR CORRUPT JARFILE" on the internet!
I recommend extracting the jar file (downloaded) and compare to the files with the jar generated locally. (You can compare the size of jar).
Can you show me your dockerfile, please?
from gs-spring-boot-docker.
FROM openjdk:8-jre
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} techlaviya.jar
RUN bash -c 'touch /techlaviya.jar'
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=container","-jar","/techlaviya.jar"]
from gs-spring-boot-docker.
version: '3'
services:
docker-mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=12345
- MYSQL_DATABASE=TechlaviyaDB
- MYSQL_PASSWORD=12345
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- docker-mysql
environment:
PMA_HOST: docker-mysql
PMA_PORT: 3306
ports:
- '8081:80'
docker-webapp:
image: techlaviya/techlaviya:0.0.1-SNAPSHOT
depends_on:
- docker-mysql
ports:
- 8080:8080
environment:
- DATABASE_HOST=docker-mysql
- DATABASE_USER=root
- DATABASE_PASSWORD=12345
- DATABASE_NAME=TechlaviyaDB
- DATABASE_PORT=3306
from gs-spring-boot-docker.
4.0.0
<groupId>com.tech.techlaviya</groupId>
<artifactId>techlaviya</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>techlaviya</name>
<description>Techlaviya Rest API Project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.RELEASE</spring-cloud.version>
<start-class>com.tech.techlaviya.TechlaviyaApplication</start-class>
<docker.image.prefix>techlaviya</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>techlaviya</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.tech.techlaviya.TechlaviyaApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
from gs-spring-boot-docker.
Running with a database is out of scope for this guide. If you want to see some guidance, maybe open an issue in the extended topical guide.
from gs-spring-boot-docker.
Related Issues (20)
- Failed jar extraction on command
- Remove references to deprecated boot2docker
- Different java versions in pom and docker
- https://spring.io/guides/gs/spring-boot-docker/ gives 404 HOT 1
- Spring-boot HOT 1
- Invalid or corrupt jarfile /application.jar
- Change 'CF memory calculator" to "buildpack memory calculator"
- Improve the note regarding the external volume for /tmp in the Dockerfile HOT 4
- Add a note about the effect on classpath ordering of exploding the jar
- s
- COPY failed: stat /var/lib/... no such file or directory HOT 1
- How to achieve Key Vault feature in azure-keyvault-secrets-spring-boot by deploying in appservice as a docker image HOT 1
- docker --build-args vs --build-arg HOT 1
- Who does regularly clean up /tmp in a long running container? HOT 6
- az acr login && mvn compile jib:build fails with I/O error for image HOT 2
- Update this guide with Boot 2.3 features HOT 5
- Update Guide For zsh users(gradle dockerizing not working)
- zsh: no matches found: JAR_FILE=build/libs/*.jar
- Documentation improvement regarding image building options
- documentation - README.adoc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gs-spring-boot-docker.