I am using a Jenkins pipeline to build a Dockerfile.
The dockerfile successfully goes through all steps, and creates the docker image.
As shown:
<
I'm getting this problem because I'm using --target= to build my image only up to a certain point.
So my Dockerfile looks like this
FROM maven:3.6-jdk-8 AS BUILD
.. do build ..
FROM openjdk:8
COPY --from=BUILD /myapp/bin my_jar_file
And my build with docker.build( fails with:
java.io.IOException: Cannot retrieve .Id from 'docker inspect openjdk:8'
This is because Jenkins is trying to inspect the second FROM openjdk:8 in the Dockerfile, and because that target didn't run Docker didn't pull down that image and it's unavailable to docker inspect
I've got a bunch of workarounds available to me:
docker pull openjdk:8 before building--target=BUILD from my docker.build command and let it build the whole thing (not too big a deal for me as the build is the most expensive part)docker.build and just sh "docker build --target=BUILD .At the moment I'm not sure which one I'll go with