dockerfile syntax error
DockerERRORBuildHIGH confidence

Instruction in Dockerfile is unknown or malformed

What this means

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.

Why it happens
  1. 1Misspelling an instruction (e.g., 'RUNN' instead of 'RUN').
  2. 2Providing the wrong number of arguments to an instruction (e.g., 'ENV VAR' instead of 'ENV VAR=value').
  3. 3Placing an instruction before the required 'FROM' instruction.
  4. 4Malformed JSON in an instruction that expects it (e.g., using single quotes in a CMD exec-form array).
How to reproduce

A Dockerfile contains a typo in one of its instructions.

trigger — this will error
trigger — this will error
# 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'.

Correct the Instruction Spelling and Syntax
# 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.

Use a Linter for Dockerfiles
# 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'.

What not to do

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

← All Docker errors