Dockerfile.layered throwing error while building docker image
pranaylonkar19 opened this issue · comments
I am getting the following error when I try to build a docker image using the Dockerfile.layered
=> ERROR [builder 4/4] RUN java -Djarmode=layertools -jar app.jar extract 0.3s
--------------------
2 | WORKDIR extracted
3 | ADD build/libs/*.jar app.jar
4 | >>> RUN java -Djarmode=layertools -jar app.jar extract
5 |
6 | FROM eclipse-temurin:17.0.4.1_1-jre
--------------------
ERROR: failed to solve: process "/bin/sh -c java -Djarmode=layertools -jar app.jar extract" did not complete successfully: exit code: 1
Someone has already asked this question on Stackoverflow
OS: Windows11
Docker: Docker Desktop 4.25.0 (126437)
I am getting the following error when I try to build a docker image using the
Dockerfile.layered
=> ERROR [builder 4/4] RUN java -Djarmode=layertools -jar app.jar extract 0.3s -------------------- 2 | WORKDIR extracted 3 | ADD build/libs/*.jar app.jar 4 | >>> RUN java -Djarmode=layertools -jar app.jar extract 5 | 6 | FROM eclipse-temurin:17.0.4.1_1-jre -------------------- ERROR: failed to solve: process "/bin/sh -c java -Djarmode=layertools -jar app.jar extract" did not complete successfully: exit code: 1
Someone has already asked this question on Stackoverflow
OS: Windows11 Docker: Docker Desktop 4.25.0 (126437)
Hi, I have also been following that tutorial (thanks a looot to brother Sai Upadhyayula), and also faced this issue too))
This error raised because docker cannot find MANIFEST.MF file in tha jar. You can check it by typing:
java -Djarmode=layertools -jar target/demo-0.0.1-SNAPSHOT.jar list
If you haven't fixed the issue yet, follow these steps:
- Add this plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
</plugin>
-
In terminal, type:
mvn clean package
Note: You should have maven installed locally -
Try viewing the contents of the newly generated jar file:
java -Djarmode=layertools -jar target/demo-0.0.1-SNAPSHOT.jar list
Yous should see the following output:
dependencies
spring-boot-loader
snapshot-dependencies
application -
Now, you can build the image by typing:
docker build -t api-gateway-layered -f Dockerfile.layered .
@UlugbekToshmatov
Your solution is working. Thank you...
I didn't find much size difference between a normal docker image and a layered docker image.
@UlugbekToshmatov Your solution is working. Thank you...
I didn't find much size difference between a normal docker image and a layered docker image.
@pranaylonkar19 Glad my solution helped you)) You can browse baeldung and spring.io for more info.