Docker Run Bind failure
04:06 29 Dec 2025

I am trying to debug a Docker build-time bind mount using BuildKit on macOS (Docker Desktop). The goal is to mount a host directory into a RUN step to inspect its contents during the build.

Here is a minimal Dockerfile:

# syntax=docker/dockerfile:1.4
FROM busybox
RUN --mount=type=bind,source=/Users/sgu/tmp2,target=/mnt,readonly \
    sh -lc 'echo "mounted:"; ls -la /mnt || true'

I got the following error when running the build command: DOCKER_BUILDKIT=1 docker build --progress=plain -f Dockerfile.mount-debug .

Dockerfile.mount-debug:4
--------------------
   3 |     
   4 | >>> RUN --mount=type=bind,source=/Users/sgu/tmp2,target=/mnt,readonly \
   5 | >>>     sh -lc 'echo "mounted:"; ls -la /mnt || true'
   6 |     
--------------------
ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref w508wv6c1uooahbrad1gvk7jg::rmwcvhs5mm0zwicb64yatidui: "/Users/sgu/tmp2": not found
make: *** [debug-mount] Error 1

However, mounting is successful via docker run --rm -v /Users/sgu/tmp2:/tmp busybox ls -la /tmp

Environment details:

  • macOS 15.3.1 (Docker Desktop 4.55.0)

  • /Users is listed under Settings → Resources → File Sharing and The directory exists on the host

Questions:

  • Why does BuildKit report "/Users/sgu/tmp2": not found even though the directory exists and /Users is shared in Docker Desktop settings?

  • Are there any extra steps needed on macOS (permissions, Docker Desktop configuration, etc.) to make absolute host paths usable with RUN --mount=type=bind in a Dockerfile?

docker