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 argumentsCommon 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/appOr supply the legacy two-token form
If you use the space form, include both the name and the value.
Dockerfile
ENV APP_HOME /opt/appHow to prevent it
- Prefer the
ENV NAME=valueform for clarity. - Never leave an ENV with only a variable name.
- Lint Dockerfiles to catch malformed ENV lines.
Related guides
Dockerfile LABEL "Syntax error - can't find = in" in CIFix "Syntax error - can't find = in" on a Dockerfile LABEL in CI - a LABEL was given without a name=value pai…
Dockerfile "COPY requires at least two arguments" in CIFix "COPY requires at least two arguments, but only one was provided" in a Docker build in CI - a COPY instru…
Dockerfile EXPOSE "invalid containerPort" in CIFix "invalid containerPort: X" on a Dockerfile EXPOSE in CI - the port value is non-numeric or malformed, oft…