Skip to content

Comments

Fix: Environment variables can be duplicated on run #1218

Merged
katiewasnothere merged 6 commits intoapple:mainfrom
simone-panico:fix-env-duplication
Feb 21, 2026
Merged

Fix: Environment variables can be duplicated on run #1218
katiewasnothere merged 6 commits intoapple:mainfrom
simone-panico:fix-env-duplication

Conversation

@simone-panico
Copy link
Contributor

@simone-panico simone-panico commented Feb 14, 2026

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

As reported in 1212, environment variables defined in a Dockerfile (ENV) were not being overridden when passed via -e at runtime, resulting in duplicate entries in the container's environment.

Root cause: Parser.allEnv() simply merged image, env-file, and user-provided environment variables without deduplication. Since getenv() returns the first match, the image default took precedence over the user override.

Fix: allEnv() now deduplicates by key, with later sources overriding earlier ones

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@simone-panico simone-panico marked this pull request as ready for review February 14, 2026 21:34
@JaewonHur
Copy link
Contributor

@simone-panico Could you run make fmt and commit again?

@katiewasnothere katiewasnothere merged commit c48ed09 into apple:main Feb 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants