madhu3984
(Madhu3984)
January 26, 2023, 7:45pm
1
Hi Team - We are trying to build a docker image and this is a Multistage build.
docker build is erroring out with the below message
failed to compute cache key: failed to walk /opt/data/docker/data/tmp/buildkit-mount2977242485/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: lstat /opt/data/docker/data/tmp/buildkit-mount2977242485/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: no such file or directory
We are using BUILDKIT feature.
Any help on this is really appreciated.
Thanks
Madhu
meyay
(Metin Y.)
January 26, 2023, 8:29pm
2
Without seeing your Dockerfile the only thing that remains is: your COPY instruction uses a wrong path, like the error message indicates.
madhu3984
(Madhu3984)
January 26, 2023, 8:31pm
3
Sorry. Here is my Dockerfile
FROM xxxxxx/docker/openshift-poc/jre:ubi8-minimal-jre17 AS build-stage
ARG JAR_FILE=/target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM xxxxx/docker/openshift-poc/jre:ubi8-minimal-jre17
COPY --from=build-stage dependencies/ /tmp
COPY --from=build-stage snapshot-dependencies/ /tmp
COPY --from=build-stage spring-boot-loader/ /tmp
COPY --from=build-stage application/ /tmp
ENTRYPOINT [“java”, “org.springframework.boot.loader.JarLauncher”]
Thanks
meyay
(Metin Y.)
January 26, 2023, 8:38pm
4
Please use preformated text to format Dockerfile content.
I would suggest to use a second RUN instruction on your build-stage with RUN echo ${PWD} && ls -lR
Most likely the problem is that the COPY instructions do not use absolute paths for the source folders.
rimelek
(Ákos Takács)
January 26, 2023, 8:52pm
5
I can’t find it in the documentation, but the example in the docs is using absolute path and I have never tried to copy from another stage without absolute path as a source. Never even thought of doing it so I agree with @meyay , that is a very likely cause of the error message.
meyay
(Metin Y.)
January 26, 2023, 8:56pm
6
I forgot to mention why The motivation is to get debug information, so you can see the current location as absolute path and in which subfolder the folders you try to copy are.
Of course, once you identified how the absolute paths need to look like, you can remove the RUN instruction again.
madhu3984
(Madhu3984)
January 26, 2023, 9:03pm
7
Sure. thanks for that info.
let me try that and update the results here.
The interesting thing is, If I am changing my BASE image, things are working fine.
Regards,
Madhu
madhu3984
(Madhu3984)
January 26, 2023, 9:26pm
8
Here is the output I see after adding the second RUN instruction.
=> [build-stage 4/4] RUN echo ${PWD} && java -Djarmode=layertools -jar application.jar extract && echo ${PWD} && ls -lR 1.7s
=> => # -rw-r–r–. 1 root root 293 Feb 1 1980 JarMode.class
=> => # -rw-r–r–. 1 root root 2201 Feb 1 1980 JarModeLauncher.class
=> => # -rw-r–r–. 1 root root 1292 Feb 1 1980 TestJarMode.class
=> => # ./spring-boot-loader/org/springframework/boot/loader/util:
=> => # total 8
=> => # -rw-r–r–. 1 root root 5174 Feb 1 1980 SystemPropertyUtils.class
###############################
I removed the second stage in my Dockerfile and built the image…I see the folders that I am trying to copy in the second stage are available on the container filesystem under /
drwxr-xr-x. 2 root root 6 Jan 26 11:33 snapshot-dependencies
drwxr-xr-x. 3 root root 16 Jan 26 11:33 spring-boot-loader
drwxr-xr-x. 4 root root 36 Jan 26 11:33 application
drwxr-xr-x. 3 root root 21 Jan 26 11:33 dependencies
[root@5917b498bdfe /]# pwd
/
#####################################################
Thanks
madhu3984
(Madhu3984)
January 26, 2023, 9:39pm
9
#7 [builder 3/3] RUN java -Djarmode=layertools -jar application.jar extract && echo ${PWD} && ls -l
#7 sha256:219e16016c8c23ebfa340a15a5377d845e0c04a014b63000e0dccace803de9a6
#7 1.635 /
#7 1.640 total 53176
#7 1.640 drwxr-xr-x. 4 root root 36 Jan 26 15:38 application
#7 1.640 -rw-r–r–. 1 root root 54434855 Jan 26 11:06 application.jar
#7 1.640 lrwxrwxrwx. 1 root root 7 Jun 21 2021 bin → usr/bin
#7 1.640 dr-xr-xr-x. 2 root root 6 Jun 21 2021 boot
#7 1.640 drwxr-xr-x. 3 root root 21 Jan 26 15:38 dependencies
#7 1.640 drwxr-xr-x. 5 root root 340 Jan 26 15:38 dev
#7 1.640 drwxr-xr-x. 1 root root 4096 Dec 15 13:37 etc
#7 1.640 drwxr-xr-x. 2 root root 6 Jun 21 2021 home
#7 1.640 lrwxrwxrwx. 1 root root 7 Jun 21 2021 lib → usr/lib
#7 1.640 lrwxrwxrwx. 1 root root 9 Jun 21 2021 lib64 → usr/lib64
#7 1.640 drwx------. 2 root root 6 Sep 6 12:17 lost+found
#7 1.640 drwxr-xr-x. 2 root root 6 Jun 21 2021 media
#7 1.640 drwxr-xr-x. 2 root root 6 Jun 21 2021 mnt
#7 1.640 drwxr-xr-x. 1 root root 17 Dec 15 13:37 opt
#7 1.640 dr-xr-xr-x. 236 root root 0 Jan 26 15:38 proc
#7 1.640 dr-xr-x—. 3 root root 4096 Sep 6 12:24 root
#7 1.640 drwxr-xr-x. 1 root root 4096 Dec 15 13:37 run
#7 1.640 lrwxrwxrwx. 1 root root 8 Jun 21 2021 sbin → usr/sbin
#7 1.640 drwxr-xr-x. 2 root root 6 Jan 26 15:38 snapshot-dependencies
#7 1.640 drwxr-xr-x. 3 root root 16 Jan 26 15:38 spring-boot-loader
#7 1.640 drwxr-xr-x. 2 root root 6 Jun 21 2021 srv
#7 1.640 dr-xr-xr-x. 13 root root 0 Oct 31 20:39 sys
#7 1.640 drwxrwxrwt. 1 root root 28 Jan 26 15:38 tmp
#7 1.640 drwxr-xr-x. 1 root root 75 Sep 6 12:17 usr
#7 1.640 drwxr-xr-x. 1 root root 38 Sep 6 12:17 var
#7 DONE 2.5s
#8 [stage-1 2/5] COPY --from=builder dependencies/ /
#8 sha256:efe19f075625e924493bbec32599cb5eecda4227631d78004b9352975f2aa728
#8 CACHED
#9 [stage-1 3/5] COPY --from=builder snapshot-dependencies/ /
#9 sha256:576ab9b6d9a000b79634f5e01b190f2dfe6ec9836fcc8c2be70dd69e34d1e571
#9 ERROR: failed to walk /opt/data/docker/data/tmp/buildkit-mount4132688350/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: lstat /opt/data/docker/data/tmp/buildkit-mount4132688350/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: no such file or directory
#8 [stage-1 2/5] COPY --from=builder dependencies/ /
#8 sha256:efe19f075625e924493bbec32599cb5eecda4227631d78004b9352975f2aa728
#8 ERROR: failed to walk /opt/data/docker/data/tmp/buildkit-mount4136272112/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: lstat /opt/data/docker/data/tmp/buildkit-mount4136272112/usr/lib/.build-id/01/e11c545160c74b88b9ce9259e7467863eab9e7: no such file or directory
Thanks
meyay
(Metin Y.)
January 26, 2023, 9:42pm
10
Please format the outputs according this post , so it gets easier to read.
meyay
(Metin Y.)
January 26, 2023, 9:48pm
11
It is like @rimelek and I already wrote: it’s the lack of absolute paths.
Try:
FROM xxxxxx/docker/openshift-poc/jre:ubi8-minimal-jre17 AS build-stage
ARG JAR_FILE=/target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM xxxxx/docker/openshift-poc/jre:ubi8-minimal-jre17
COPY --from=build-stage /dependencies/ /tmp/
COPY --from=build-stage /snapshot-dependencies/ /tmp/
COPY --from=build-stage /spring-boot-loader/ /tmp/
COPY --from=build-stage /application/ /tmp/
ENTRYPOINT [“java”, “org.springframework.boot.loader.JarLauncher”]
madhu3984
(Madhu3984)
January 27, 2023, 1:36am
12
Tried with above Dockefile and still same error.
Regards,
Madhu M
madhu3984
(Madhu3984)
January 27, 2023, 2:32am
13
Also another thing that I noticed is, same Dockerfile is working fine when I try to run/build the image from different machine.
So I am not sure what’s going on on the machine where the build is failing.
Regards,
Madhu M
meyay
(Metin Y.)
January 27, 2023, 7:14am
14
Are you sure your machine uses an official Docker Distribution (Docker Desktop/Docker-CE) from Docker’s official repositories?
Please do not ignore this.
madhu3984
(Madhu3984)
January 27, 2023, 2:00pm
15
Machine where this is failing:
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:02:38 2022
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.6.9
GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
madhu3984
(Madhu3984)
January 27, 2023, 2:01pm
16
and Machine on which same Dockerfile is working
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:02:19 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:00:24 2022
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.6.11
GitCommit: d986545181c905378b0f90faa9c5eae3cbfa3755
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
ayaa001
(Ayaa001)
September 14, 2023, 2:52pm
18
@madhu3984 please, were you able to find a solution to the issue? I’m currently facing the same issue