TL;DR: The `--target` name does not match any `FROM ... AS [name]` in the Dockerfile. List your stage aliases (`grep -n "^FROM" Dockerfile`) and fix the typo or the renamed stage. Stage names are case-sensitive and must match exactly.

## The error

```text
failed to solve: target stage "builder" could not be found
```

## Fix it

1. List the stages actually defined:
   `grep -n "^FROM" Dockerfile`
   Expected: lines like `FROM node:20 AS build` showing the real alias.
2. Fix the mismatch, either the build command:
   `docker build --target build .`
   or the Dockerfile alias:
   `FROM node:20 AS builder`
3. Rebuild.

## When this applies
- `docker build --target [name]` with a misspelled or stale stage name
- Dockerfiles refactored to rename stages without updating CI scripts

## When this does NOT apply
- `COPY --from=[name]` failing (that names the source stage in the Dockerfile itself; check the alias there)
- "failed to read dockerfile" (file missing, earlier failure)

## Versions
All BuildKit versions; classic builder says "failed to find stage" variants.

## Why it happens
`--target` selects which stage to build up to. BuildKit resolves the name against the `AS` aliases parsed from the Dockerfile; anything else is an error, and the message quotes the name you passed so you can diff it against the file.

## Edge cases
- Stage names are case-sensitive: `AS Builder` is not `--target builder`.
- A stage defined AFTER the target in file order is fine; order does not matter, only the name.
- `docker buildx bake` targets are defined in the bake file, not the Dockerfile; a bake target typo produces a different error.
