Skip to content
Latchkey

Dockerfile "ENV must have two arguments" in CI

The parser rejected an ENV that has a key but no value. The legacy form ENV NAME value needs both tokens, and ENV NAME alone is invalid.

What this error means

docker build fails at parse time with "ENV must have two arguments" when a Dockerfile contains an ENV line with only a variable name.

docker build
Dockerfile:5
--------------------
   5 | >>> ENV APP_HOME
--------------------
ENV must have two arguments

Common causes

A variable name with no value

The line is ENV APP_HOME with nothing after it, so there is no value to assign.

A missing equals in the key=value form

Mixing forms (for example ENV APP_HOME then a separate value line) leaves a single bare token.

How to fix it

Use the key=value form

Assign a value with = so the instruction is unambiguous.

Dockerfile
ENV APP_HOME=/opt/app

Or supply the legacy two-token form

If you use the space form, include both the name and the value.

Dockerfile
ENV APP_HOME /opt/app

How to prevent it

  • Prefer the ENV NAME=value form for clarity.
  • Never leave an ENV with only a variable name.
  • Lint Dockerfiles to catch malformed ENV lines.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →