Problem
The buildkit does not allow mounting an image to an ONBUILD RUN command. When I mount an image in an ONBUILD RUN command, then use that as a base for another image, I get the following error:
=> ERROR [2/1] RUN --mount=type=bind,from=tomcat:latest,src=/usr/local/tomcat/BUILDING.txt,dst=/BUILDING.txt 0.2s ------ > [2/1] RUN --mount=type=bind,from=tomcat:latest,src=/usr/local/tomcat/BUILDING.txt,dst=/BUILDING.txt: #7 0.125 container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/tmp/buildkit-mount356322217/usr/local/tomcat/BU ILDING.txt\\\" to rootfs \\\"/var/lib/docker/buildkit/executor/y76nt87kgf7bikqmd23wzq8ed/rootfs\\\" at \\\"/BUILDING.txt\\\" caused \\\"stat /var/lib/docker/tmp/buildkit-mount356322217/usr/local/tomcat/BUILDING .txt: no such file or directory\\\"\"" --------
Steps To Reproduce
I have a "base" dockerfile that looks like this:
# syntax = docker/dockerfile:1.0-experimental FROM ubuntu:16.04
ONBUILD RUN --mount=type=bind,from=tomcat:latest,src=/usr/local/tomcat/BUILDING.txt,dst=/BUILDING.txt
Then I have a service dockerfile that looks like this:
# syntax = docker/dockerfile:1.0-experimental
FROM base
Attempting to build this service image produces the above error.
Use Case
I am trying to create a base image for several services used by my company. That base image is supposed to contain all the building blocks needed to run the service, but should not actually build them (hence the use of the ONBUILD command). So we start with an operating system and layer in standard shared utilities and/or files. Each service uses this base image, then adds in only service-specific files.
Problem
The buildkit does not allow mounting an image to an ONBUILD RUN command. When I mount an image in an ONBUILD RUN command, then use that as a base for another image, I get the following error:
=> ERROR [2/1] RUN --mount=type=bind,from=tomcat:latest,src=/usr/local/tomcat/BUILDING.txt,dst=/BUILDING.txt 0.2s ------ > [2/1] RUN --mount=type=bind,from=tomcat:latest,src=/usr/local/tomcat/BUILDING.txt,dst=/BUILDING.txt: #7 0.125 container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/tmp/buildkit-mount356322217/usr/local/tomcat/BU ILDING.txt\\\" to rootfs \\\"/var/lib/docker/buildkit/executor/y76nt87kgf7bikqmd23wzq8ed/rootfs\\\" at \\\"/BUILDING.txt\\\" caused \\\"stat /var/lib/docker/tmp/buildkit-mount356322217/usr/local/tomcat/BUILDING .txt: no such file or directory\\\"\"" --------Steps To Reproduce
I have a "base" dockerfile that looks like this:
Then I have a service dockerfile that looks like this:
Attempting to build this service image produces the above error.
Use Case
I am trying to create a base image for several services used by my company. That base image is supposed to contain all the building blocks needed to run the service, but should not actually build them (hence the use of the ONBUILD command). So we start with an operating system and layer in standard shared utilities and/or files. Each service uses this base image, then adds in only service-specific files.