dockerfile parse error on line 3: unknown instruction: COPPY (did you mean COPY?)
means the first word on that line of your Dockerfile is not a Dockerfile instruction. Here it
is a typo; fix the word on the line the message names and build again.
Read the word after unknown instruction: first. If it is a misspelled keyword,
correct it. If it is something that is not a keyword at all, such as a shell command, that
line lost its RUN, or the line above lost its trailing backslash.
The error
Dockerfile:3
--------------------
1 | FROM alpine
2 | RUN apk add --no-cache curl
3 | >>> COPPY . /app
4 |
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 3: unknown instruction: COPPY (did you mean COPY?)
The build exited with code 1 before any step ran. Unlike the build-check warnings, this is a hard error: Docker cannot read the file, so nothing is built.
Why it happens
Every line of a Dockerfile, apart from comments, blank lines and continuations of the line
above, must start with an instruction such as FROM, RUN,
COPY or ENV. The parser reads the whole file before the build
starts and stops at the first word it does not know. When the word is close to a real
keyword, as COPPY is, the message adds a suggestion in brackets.
The second common cause is a continuation that broke. A file with a comment on line 1, a
blank line 3, RUN apk add --no-cache curl on line 4 without a trailing
backslash and an indented apk add --no-cache git on line 5 failed like this:
Dockerfile:5
--------------------
3 |
4 | RUN apk add --no-cache curl
5 | >>> apk add --no-cache git
6 |
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 5: unknown instruction: apk (did you mean arg?)
The suggestion arg is a guess at a near spelling, not the fix; a second run of
the same file suggested add instead. Ending line 4
with && \ made line 5 part of the same RUN; that build
installed both packages and exited with 0. The line number counted the comment and the blank line, so it matches
what your editor shows.
The fix
FROM alpine
RUN apk add --no-cache curl
COPY . /app
With line 3 corrected, the same build command ran both steps and exited with code 0. The broken file differed only in that one word.
How it was reproduced
A three-line Dockerfile on alpine with a misspelled COPY, built with
docker build --progress=plain -t fix8-bld-q6 fix8-bld-q6 on Docker Desktop
engine 29.9.2, then the corrected file built into fix8-bld-q6fix. Tags and
folders are this test's own.
Frequently asked
- What does unknown instruction mean in a Dockerfile?
- The first word on the named line is not a Dockerfile instruction, often a typo such as COPPY for COPY. Docker stops before building anything.
- Which line does dockerfile parse error on line 3 mean?
- Line 3 of the Dockerfile counted from the top. The error output also prints the surrounding lines and marks the failing one with >>>.
- Is unknown instruction a warning or an error?
- An error. The build exits with code 1 and no step runs, unlike the build-check warnings that let the build finish.
More decoded errors in the Fixes category. If the file parses but a step fails with exit code 127, see '/bin/sh: 1: curl: not found'.