You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] docker compose config --no-consistency no longer working as expected #13974
I have two systems, one running docker compose v2.20.3 and another one at compose v5.1.3. (Those seem massively apart, given the relatively short span of time between their installation.)
On v2.20.3 I rely on docker compose config --no-consistency --dry-run to parse compose projects and extract useful information (I wrote a pre-processor to inject repetitive statements across my projects, including the "build" section).
Without the --no-consistency flag docker compose would rightfully output that service "XYZ" has neither an image nor a build context specified: invalid compose project, because it has no build nor image specified.
On v5.1.3, despite using the --no-consistency flag, compose always reports an invalid compose project, which prevents the parsing of the compose file from completing.
I couldn't reproduce it with the exact command, but there is a real gap here. On v5.3.1 (Docker 29.6.2), with a compose.yaml containing a single service that has neither image nor build, --no-consistency is honoured by plain config but silently ignored as soon as a sub-flag is used:
config --no-consistency exit 0
config --no-consistency --dry-run exit 0
config --services --no-consistency exit 1 service "novalid" has neither an image nor a build context specified
config --volumes --no-consistency exit 1 (same)
config --networks --no-consistency exit 1 (same)
config --models --no-consistency exit 1 (same)
config --hash '*' --no-consistency exit 1 (same)
The cause looks straightforward: runServices / runVolumes / runNetworks / runModels / runHash call opts.ProjectOptions.ToProject(ctx, dockerCli, backend, nil, cli.WithoutEnvironmentResolution) directly (cmd/compose/config.go 494 / 512 / 528 / 544 / 567) instead of passing opts.toProjectOptionsFns().... That drops the whole set built at config.go:78 — not only WithConsistency, but also WithInterpolation, WithResolvedPaths, WithNormalization and WithDefaultProfiles. Those paths also apply WithoutEnvironmentResolution unconditionally, independent of --no-env-resolution.
@exophoric which form were you running? If it really was plain config --no-consistency --dry-run, that works here on 5.3.1 and your case is something else.
I'm happy to open a PR passing opts.toProjectOptionsFns()... on those five paths plus a regression test. One question for the maintainers: should the unconditional WithoutEnvironmentResolution be kept as-is on those paths for backwards compatibility, or folded into the same fix?
Hi again, here's a minimal example. I also bisected which exact version causes this, and it's really when compose 5.0.0 was released.
mkdir -p ~/compose-test/
cat <<EOF > ~/compose-test/stack.ymlservices: server: environment: FOO: barEOF# Docker Compose version v2.40.3
docker run --rm -ti -v ~/compose-test:/srv/compose-test docker:29.1.1-cli compose -f /srv/compose-test/stack.yml config --dry-run --no-consistency --services
# Correctly outputs "server"# Docker Compose version v5.0.0
docker run --rm -ti -v ~/compose-test:/srv/compose-test docker:29.1.2-cli compose -f /srv/compose-test/stack.yml config --dry-run --no-consistency --services
# Fails with error "service "server" has neither an image nor a build context specified: invalid compose project"
Again, this use-case might appear silly at first glance, but I'm adding boiler-plate build instructions (that include complex layer caching directives) through a simple "pre-processor" script I wrote. (The compose files we write are also used on docker swarm). This "pre-processor" uses docker compose config to parse the base config. The whole idea is to avoid having to copy paste the complex build statement across the many micro-services of our environment. It also keeps that logic in a separate location we can easily update.
Activity
g1mn commentedon Jul 28, 2026
I couldn't reproduce it with the exact command, but there is a real gap here. On v5.3.1 (Docker 29.6.2), with a
compose.yamlcontaining a single service that has neitherimagenorbuild,--no-consistencyis honoured by plainconfigbut silently ignored as soon as a sub-flag is used:The cause looks straightforward:
runServices/runVolumes/runNetworks/runModels/runHashcallopts.ProjectOptions.ToProject(ctx, dockerCli, backend, nil, cli.WithoutEnvironmentResolution)directly (cmd/compose/config.go494 / 512 / 528 / 544 / 567) instead of passingopts.toProjectOptionsFns().... That drops the whole set built atconfig.go:78— not onlyWithConsistency, but alsoWithInterpolation,WithResolvedPaths,WithNormalizationandWithDefaultProfiles. Those paths also applyWithoutEnvironmentResolutionunconditionally, independent of--no-env-resolution.@exophoric which form were you running? If it really was plain
config --no-consistency --dry-run, that works here on 5.3.1 and your case is something else.I'm happy to open a PR passing
opts.toProjectOptionsFns()...on those five paths plus a regression test. One question for the maintainers: should the unconditionalWithoutEnvironmentResolutionbe kept as-is on those paths for backwards compatibility, or folded into the same fix?exophoric commentedon Jul 29, 2026
Hi again, here's a minimal example. I also bisected which exact version causes this, and it's really when compose 5.0.0 was released.
Again, this use-case might appear silly at first glance, but I'm adding boiler-plate build instructions (that include complex layer caching directives) through a simple "pre-processor" script I wrote. (The compose files we write are also used on docker swarm). This "pre-processor" uses
docker compose configto parse the base config. The whole idea is to avoid having to copy paste the complex build statement across the many micro-services of our environment. It also keeps that logic in a separate location we can easily update.