Instruction in Dockerfile is unknown or malformed
This category covers errors found by the Docker builder when parsing a Dockerfile. It happens when an instruction is misspelled, used with incorrect arguments, or placed in an invalid order, preventing the image build from starting.
- 1Misspelling an instruction (e.g., 'RUNN' instead of 'RUN').
- 2Providing the wrong number of arguments to an instruction (e.g., 'ENV VAR' instead of 'ENV VAR=value').
- 3Placing an instruction before the required 'FROM' instruction.
- 4Malformed JSON in an instruction that expects it (e.g., using single quotes in a CMD exec-form array).
A Dockerfile contains a typo in one of its instructions.
# Dockerfile FROM ubuntu:22.04 # Misspelled instruction 'COPPY' COPPY . /app
expected output
failed to solve with frontend dockerfile.v0: failed to create LLB definition: Dockerfile parse error line 3: unknown instruction: COPPY
Fix 1
Correct the Instruction Spelling and Syntax
WHEN The error message indicates an 'unknown instruction' or 'parse error'.
# Corrected Dockerfile FROM ubuntu:22.04 COPY . /app
Why this works
Fixing the typo or syntax to match the official Dockerfile specification allows the builder to parse the file correctly.
Fix 2
Use a Linter for Dockerfiles
WHEN To proactively catch syntax errors and enforce best practices in your IDE.
# Example of using 'hadolint' hadolint Dockerfile
Why this works
A linter like Hadolint statically analyzes your Dockerfile and flags syntax errors, security issues, and violations of best practices before you even run 'docker build'.
✕ Ignore linter warnings.
While some warnings might be stylistic, many point to potential bugs, security vulnerabilities, or inefficient image builds. It's best practice to address them.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev