[FEATURE] Report all missing required environment variables in a single error

未关闭
#14,471 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker-compose, go
领域
cli

调研方向

Start by tracing environment variable interpolation and required-variable validation in Docker Compose; the issue names no source files or tests. Check how docker compose config and docker compose up handle multiple missing variables, then identify the relevant tests. Done means both commands report all missing required variables together and start no containers when validation fails.

由索引模型根据 Issue 内容生成。

描述

kind/feature status/0-triage
Description

When a Compose file contains multiple required environment variables, Docker Compose stops at the first missing variable during interpolation.
This means users must repeatedly run docker compose up, fix one variable, and run the command again to discover the next missing variable.
It would be helpful to collect all missing required variables and report them together before exiting.

Example

services:
  app:
    image: alpine:latest
    environment:
      DB_HOST: ${DB_HOST:?DB_HOST is required}
      DB_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD is required}
      API_KEY: ${API_KEY:?API_KEY is required}

With all three variables unset, run:

docker compose up

Current behavior
Compose exits after reporting a single missing required variable. The remaining missing variables are discovered only on subsequent attempts.

Expected behavior
Compose validates all required variables and returns one consolidated error, for example:

Configuration validation failed:
  - DB_HOST: DB_HOST is required
  - DB_PASSWORD: DB_PASSWORD is required
  - API_KEY: API_KEY is required

No containers should be started when validation fails.
This behavior would be useful for both docker compose up and docker compose config.

Benefits

  • Reduces repeated configuration attempts.
  • Makes initial setup easier for projects with many required variables.
  • Provides clearer feedback in CI/CD logs.

Docker Compose version

PS C:\Users\<user>> docker compose version
Docker Compose version v5.3.1
PS C:\Users\<user>> docker version
Client:
 Version:           29.6.2-rd
 API version:       1.55
 Go version:        go1.26.4
 Git commit:        ede120b
 Built:             Fri Jul 17 17:00:40 2026
 OS/Arch:           windows/amd64
 Context:           default
主要语言
Go
星标
38.9k
派生
6k
平均合并
2 天 22 小时
30 天内合并 PR
81

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/compose 的其他 Issue

查看 docker/compose 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。