Skip to content

[BUG] docker compose config --no-consistency no longer working as expected #13974

Closed

Description

@exophoric

Description

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.

Steps To Reproduce

No response

Compose Version


Docker Environment


Anything else?

No response

Activity

  1. g1mn commented on Jul 28, 2026

    @g1mn

    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?

  2. self-assigned this
    on Jul 28, 2026
  3. exophoric commented on Jul 29, 2026

    @exophoric
    Author

    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.yml
    services:
      server:
        environment:
          FOO: bar
    EOF
    
    # 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions