I’m trying to create a multi-stage Dockerfile
FROM openjdk:11.0.7-jre-slim-buster AS build
... additional commands
RUN mkdir -p target/exploded && (cd target/exploded; jar -xf ../*.jar)
But it fails when trying to explode the .jar file, it is present under the target directory:
=> ERROR [build 7/7] RUN mkdir -p target/exploded && (cd
target/exploded; jar -xf ../*.jar)
/bin/sh: 1: jar: not found
------
executor failed running [/bin/sh -c mkdir -p target/exploded && (cd target/exploded;
jar -xf ../*.jar)]: exit code: 127
2
Answers
I'm including Spring Cloud Contract as a dependency, it generates a ...stubs.jar file, causing a Docker conflict as it can't choose the proper jar to be exploded, now I'm updating the Dockerfile to target the correct .jar file.
I suggest you to debug where the
jar
command is, in order to fully address it in your call by a:The remove this line and prepend the found path to your
jar
invocation.