I'm trying to use BuildKit RUN --mount=type=bind to mount a directory that is two levels up from the docker context dir. Here is a simplified dir structure.
project (dir)
app (dir)
docker (dir)
docker-compose.yaml (file)
some-dir1 (dir)
app (dir)
Dockerfile (file)
some-file (file)
project/app is the dir containing the java project build with gradle. project/docker/app is a docker context of the image that will contain the app.
Here is the Dockerfile:
# syntax=docker/dockerfile:1.2
FROM gradle:8.3.0-jdk17-alpine as builder
RUN --mount=type=bind,target=/home/gradle/app/,source="../../app/",rw \
cd /home/gradle/app/ && \
gradle clean && \
gradle bootJar
When I'm trying to build docker image I get the error that docker doesn't see ../../app dir.
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 2f6eb37e-c9dd-424b-bc15-b41d19994e1c::eg16xi09kr6tsssono9tcri5e: "/app": not found
Is it possible to mount dir from outside of the docker context?