Legacy `ENV key value` with a multi-word value becomes an invalid `key=value`

Open Beginner friendly
#69 1 comment 0 reactions 0 assignees View on GitHub

@RyoKusnadi is already working on this.

Since Nov 5, 2026.

  • #74 by @RyoKusnadi — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, go
Domain
devtools, tooling

Research direction

Start by tracing how dockerfmt parses and converts legacy ENV key value instructions, then find the formatter tests for ENV handling. Reproduce with the supplied JAVA_OPTS example and add coverage for a multi-word value. Done means formatting produces valid Dockerfile syntax that builds and can be formatted again.

Written by the indexing model from the issue text.

Description

Converting a legacy ENV key value instruction to the key=value form breaks when the value contains spaces. The output is not a valid Dockerfile: docker build rejects it, and so does dockerfmt on the next run.

Reproduce
FROM alpine
ENV JAVA_OPTS -Xms256m -Xmx512m
dockerfmt Dockerfile
Actual
FROM alpine
ENV JAVA_OPTS=-Xms256m -Xmx512m

The original builds and sets JAVA_OPTS=-Xms256m -Xmx512m. docker build on the output, and dockerfmt run on it again, both fail with:

Error parsing file: Syntax error - can't find = in "-Xmx512m". Must be of the form: name=value
Expected

In the legacy form everything after the key is the value, so the converted instruction needs quotes:

ENV JAVA_OPTS="-Xms256m -Xmx512m"

Leaving the instruction in its legacy form would also be correct.

Impact

With --write the Dockerfile no longer builds. In a sample of about 450 real-world Dockerfiles, 112 lines used the legacy ENV form and one of them had an unquoted multi-word value.

Reproduced with v0.5.4 and with main at a5868c2.

Dominant language
Go
Stars
626
Forks
23
Avg merge
6d 23h
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reteps/dockerfmt

All issues in reteps/dockerfmt

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.