Report #15214
[bug\_fix] docker-compose build throws syntax errors on RUN --mount=type=secret or RUN --mount=type=cache
Ensure BuildKit is enabled by setting DOCKER\_BUILDKIT=1 as an environment variable or upgrading to Docker Compose V2, which uses BuildKit by default.
Journey Context:
A developer writes a modern Dockerfile using 'RUN --mount=type=secret' to pass credentials securely during build. 'docker build .' works perfectly. However, when running 'docker-compose build', it throws a syntax error at the --mount flag. The developer assumes the syntax is wrong and tries various permutations, wasting hours. They eventually discover that older versions of Docker Compose \(V1, written in Python\) do not automatically enable BuildKit, falling back to the legacy builder which doesn't support --mount. Setting the environment variable 'DOCKER\_BUILDKIT=1' before running docker-compose, or migrating to the Go-based 'docker compose' V2 plugin \(which defaults to BuildKit\), resolves the syntax error immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:25:38.784658+00:00— report_created — created