Skip to content

[Bug]: container build fails when using --mount type=tmpfs in RUN commands. #2405

Closed

Description

@jglogan

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Dockerfile:

FROM alpine:3.20

# A COPY with more than one source from the build context ...
COPY a.txt b.txt /out/

# ... followed by a RUN step with a tmpfs mount.
RUN --mount=type=tmpfs,dst=/scratch ls -l /out

repro.sh:

#!/bin/bash
#
# Minimal reproducer: a multi-source COPY fails with "not found" when a later
# RUN step has a tmpfs mount.
#
# Usage: ./repro.sh            (uses `container` from PATH)
#        CONTAINER=/path/to/container ./repro.sh
#
# Expected with an affected builder:
#   1. control build  (no tmpfs mount):   succeeds
#   2. repro build    (with tmpfs mount): fails on the COPY with an error like
#        failed to calculate checksum of ref ...: "/b.txt": not found
#
# The context holds both files, so the error is misleading. Only the first
# source of the COPY (a.txt) reaches the builder.

set -euo pipefail

CONTAINER="${CONTAINER:-container}"
here="$(cd "$(dirname "$0")" && pwd)"

ctx="$(mktemp -d)"
trap 'rm -rf "$ctx"' EXIT

cp "$here/Dockerfile" "$ctx/Dockerfile"
echo one >"$ctx/a.txt"
echo two >"$ctx/b.txt"

# The control is the same Dockerfile without the tmpfs mount.
sed 's/ --mount=type=tmpfs,dst=\/scratch//' "$ctx/Dockerfile" >"$ctx/Dockerfile.control"

cd "$ctx"

echo "== 1. control: same COPY, no tmpfs mount (expected to succeed)"
"$CONTAINER" build --no-cache --progress plain -f Dockerfile.control -t repro-control .

echo
echo "== 2. repro: same COPY, with RUN --mount=type=tmpfs (fails on affected builders)"
if "$CONTAINER" build --no-cache --progress plain -f Dockerfile -t repro .; then
        echo "build succeeded: this builder is not affected"
else
        echo "build failed: reproduced"
        exit 1
fi

Problem description

== 2. repro: same COPY, with RUN --mount=type=tmpfs (fails on affected builders)
Warning! Running debug build. Performance may be degraded.
#1 [resolver] fetching image...docker.io/library/alpine:3.20
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 236B done
#2 DONE 0.0s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 oci-layout://docker.io/library/alpine:3.20@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc
#4 resolve docker.io/library/alpine:3.20@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc done
#4 CACHED

#5 [internal] load build context
#5 transferring context: 34B done
#5 DONE 0.0s

#6 [linux/arm64 stage-0 1/3] COPY a.txt b.txt /out/
#6 ERROR: failed to calculate checksum of ref ri7p98qkzg8n87qxfhberaj87::n3qtmg0sidpsi73txvpai29ce: "/b.txt": not found
------
 > [linux/arm64 stage-0 1/3] COPY a.txt b.txt /out/:
------
Error: unknown: "failed to solve: failed to compute cache key: failed to calculate checksum of ref ri7p98qkzg8n87qxfhberaj87::n3qtmg0sidpsi73txvpai29ce: "/b.txt": not found"
build failed: reproduced

Environment

- OS: 27
- Xcode: 27 
- Container: main

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added this to the 26w44 milestone on Oct 16, 2026
  2. self-assigned this
    on Oct 16, 2026
  3. added theissue type on Oct 16, 2026
  4. added
    facet/builder
    on Oct 16, 2026
  5. onlyarnav commented on Oct 19, 2026

    @onlyarnav
    Contributor

    submitted #2414 to address the host-side BuildFSSync handling when followpaths is omitted

  6. jglogan commented on Oct 23, 2026

    @jglogan
    ContributorAuthor

    @onlyarnav See my note on your PR about why this the change you have is insufficient to fix the issue.

    But, we'll use this to add proper handling on the container side of the API, and to bump the container-builder-shim version. When you can, please add a CLI integration test similar to the reproducer that I included in the PR commentary, and I'll ping you here once the new c-b-s image gets published. Thank you!

  7. onlyarnav commented on Oct 24, 2026

    @onlyarnav
    Contributor

    Sure thing, i'm following up on all comments. I'll also push the CLI test asap. Thank you

  8. added a commit that references this issue on Oct 29, 2026
    305cb6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

facet/builder

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions