Dockerfile LABEL "Syntax error - can't find = in" in CI
The parser rejected a LABEL that is not written as name=value. The same check applies to ENV in key=value form: each token must contain an equals sign.
What this error means
docker build fails with "dockerfile parse error: Syntax error - can't find = in \"X\". Must be of the form: name=value" while reading a LABEL line.
docker build
dockerfile parse error line 3: Syntax error - can't find = in "maintainer". Must be of the form: name=valueCommon causes
A LABEL with no value
The line is LABEL maintainer with no =value, so the parser cannot form a key/value pair.
A malformed multi-pair LABEL
Mixing space-separated tokens that are not valid name=value pairs triggers the same error.
How to fix it
Write LABEL as name=value
Use an equals sign for each label.
Dockerfile
LABEL maintainer="team@example.com" \
org.opencontainers.image.source="https://github.com/acme/app"Quote values that contain spaces
- Confirm each label is a
name=valuepair. - Quote any value with spaces or special characters.
- Re-run the build.
How to prevent it
- Always write LABEL and ENV pairs with an equals sign.
- Quote label values that contain spaces.
- Lint Dockerfiles to catch malformed LABEL lines.
Related guides
Dockerfile "ENV must have two arguments" in CIFix "ENV must have two arguments" in a Docker build in CI - an ENV instruction names a variable but gives it…
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…