Skip to content

Dockerfile instruction error: invalid command

Quick summary

Your Dockerfile has an invalid instruction — the builder cannot parse the Dockerfile.

Why this happens

  • A Dockerfile instruction is misspelled (e.g., RUNN instead of RUN)

  • An instruction is used in the wrong context (e.g., COPY after ENTRYPOINT in a multi-stage build)

  • The instruction syntax is malformed — missing arguments or wrong format

Minimal example

✗ Broken code
FROM node:18-alpine
WORKDIR /app
COPYY . . # typo: COPYY instead of COPY
RUN npm install
CMD ["node", "server.js"]
✓ Fixed code
FROM node:18-alpine
WORKDIR /app
COPY . . # correct instruction
RUN npm install
CMD ["node", "server.js"]

Correcting the instruction name from COPYY to COPY makes the Dockerfile valid and the build succeeds.

How to diagnose

  • Read the build error message for the unknown instruction and line number

  • Check the Dockerfile reference for valid instructions and their syntax

  • Verify each instruction has the correct number of arguments and format

How to fix

  • Correct the instruction name to match a valid Dockerfile instruction

  • Move instructions to the correct context or stage in a multi-stage build

  • Fix the instruction syntax — add missing arguments or correct the format

How to prevent

  • Use a Dockerfile linter like hadolint to catch invalid instructions before building

  • Refer to the Dockerfile reference for valid instructions and their syntax

Related Resources

Related Glossary

Related Lessons

  • Docker

    Learn about Dockerfiles.

← Back to language