FromAsCasing: 'as' and 'FROM' keywords' casing do not match is a build-check
warning, not an error. The build finishes and the image is created. Docker is only pointing out
that a line such as FROM alpine as final mixes an upper-case
FROM with a lower-case as. Write AS in capitals and the
warning goes away.
The fix is one letter case on one line: FROM alpine AS final. The stage name
stays the same.
The error
1 warning found (use docker --debug to expand):
- FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 4)
These lines come at the end of the build output, after the image was exported. The build exited with code 0. In the captured log the two lines carry terminal colour codes, which are left out here; no word was changed.
Why it happens
Recent Docker versions run a set of build checks over every Dockerfile while they parse it.
The checks look for style problems and common mistakes, and they report them as warnings
under the build output. Dockerfile keywords are not case-sensitive, so
FROM alpine as final is valid and builds; the check only asks for one style
inside a single instruction.
A related check fires when a whole instruction is lower case in a file that is otherwise
upper case. Writing the line as from alpine as final in the same file produced
ConsistentInstructionCasing: Command 'from' should match the case of the command majority (uppercase) (line 4)
instead. Both are about appearance only. The image built either way.
The fix
FROM alpine AS build
RUN echo built > /out.txt
FROM alpine AS final
COPY --from=build /out.txt /out.txt
Built again with the same command, the log ended without a warning section. The broken
file differed only on line 4, FROM alpine as final. If your team writes
Dockerfiles in lower case on purpose, keep the whole file lower case,
from alpine as final on every from line; the mismatch is what the
check reports.
How it was reproduced
A two-stage Dockerfile on the alpine image, built with
docker build --progress=plain -t fix8-bld-q1 fix8-bld-q1 on Docker Desktop
with engine 29.9.2 (BuildKit, the default builder). The fixed file was built the same way
into fix8-bld-q1fix. Tags and folder names are this test's own.
Frequently asked
- Does the FromAsCasing warning break my Docker build?
- No. It is a build-check warning printed after the build. The build exits with code 0 and the image is created as usual.
- How do I fix FromAsCasing in a Dockerfile?
- Use the same case for FROM and AS on the line the warning names, for example FROM alpine AS final instead of FROM alpine as final.
- Are Dockerfile instructions case-sensitive?
- No. Lower-case instructions build too. The build checks only warn when the casing is mixed, inside one line or across the file.
More decoded errors in the Fixes category. For a full multi-stage Dockerfile for a .NET app, see building the .NET image.