Skip to content

[BUG] docker compose config --quiet produces non-deterministic result for required variables #13712

@mschoettle

Description

@mschoettle

Description

(I wasn't sure if this is better suited here or in compose-go, let me know if I should raise it there instead)

When running docker compose config --quiet on the below files, I get inconsistent results for required variables missing a variable. I noticed this when running tests on a generated compose project, every once in a while my test cases fail.

$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.environment.[]: required variable TIMEZONE is missing a value
$ docker compose config --quiet
error while interpolating services.traefik.volumes.[].source: required variable TRAEFIK_ACME_PATH is missing a value

The same happens when running docker compose up.

As a side note: Would it not be possible to show errors for all missing required variables at the same time?

Steps To Reproduce

.env:

TIMEZONE=

TRAEFIK_ACME_PATH=
TRAEFIK_LOGS_PATH=

compose:

services:
  traefik:
    container_name: traefik
    image: traefik:v3.6.11
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    environment:
      - TZ=${TIMEZONE:?}
    volumes:
      - type: bind
        source: ./traefik.yaml
        target: /etc/traefik/traefik.yaml
        read_only: true
        bind:
          create_host_path: false
      - type: bind
        source: ./config/traefik
        target: /config
        read_only: true
        bind:
          create_host_path: false
      - type: bind
        source: ${TRAEFIK_ACME_PATH:?}
        target: /acme/
        bind:
          create_host_path: false
      - type: bind
        source: ${TRAEFIK_LOGS_PATH:?}
        target: /logs
        bind:
          create_host_path: false
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        read_only: true
        bind:
          create_host_path: false

Compose Version

Docker Compose version v2.40.3

Docker Environment


Anything else?

When the required variables are all defined, similar behaviour is exhibited when running docker compose up for missing source paths in volumes:

$ docker compose up
[+] Running 1/1
 ✘ Container traefik  Error response from daemon: invalid mount config for type "bind": bind source path does...                     0.1s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /path/to/project/volumes/acme
$ docker compose up
[+] Running 1/1
 ✘ Container traefik  Error response from daemon: invalid mount config for type "bind": bind source path does...                     0.0s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /path/to/project/traefik.yaml

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions