Closed jolmg closed 1 month ago
As an additional check (since the linked commit mentions empty environment variables), changing docker compose config
for FOO=/dev/zero docker compose config
in each of the above reproduction scripts gives the same results. Same errors. The only difference is that, in the successful one, source: /dev/zero
rather than source: /dev/null
, of course.
@jolmg hi! I think the issue with the yaml, you should put empty space after ":"
- ${FOO:-/dev/null}: /tmp/foo:to
^ here
@idsulik This is the short syntax for volumes.. If I added a space, it wouldn't be a yaml string; it'd a mapping, and I'd get this error:
validating /tmp/docker-compose-interpolation-test-t9H5/docker-compose.yml: services.foo.volumes.0 type is required
Because it's then expecting the different syntax with specific keys.
@idsulik Thank you, though. Your comment does show that switching to long syntax is a good workaround for this bug.
d=/tmp/docker-compose-interpolation-test-long-syntax
set -e
mkdir "$d"
cd "$d"
cat > docker-compose.yml <<EOF
services:
foo:
extends: { file: other.yml, service: foo }
EOF
cat > other.yml <<EOF
services:
foo:
image: bash
volumes:
- type: bind
source: \${FOO:-/dev/null}
target: /tmp/foo
read_only: true
EOF
docker compose config
Result:
name: docker-compose-interpolation-test-long-syntax
services:
foo:
image: bash
networks:
default: null
volumes:
- type: bind
source: /dev/null
target: /tmp/foo
read_only: true
networks:
default:
name: docker-compose-interpolation-test-long-syntax_default
Description
Current behavior is the following error, with a stacktrace (included in reproduction steps):
I also get a different error if I remove a mount option next to the interpolation. Both configs and errors included in reproduction steps.
Expected containers to come up when I did
docker compose up
. Error(s) also happens withdocker compose config
, and it's got something to do with combining interpolation and extended files.It seems the bug was introduced in 163cdfd31, which adds a test and updates the
compose-go
dependency.Checking out
compose-go
, withcompose
set to163cdfd31~
, it seems the bug was introduced there in compose-spec/compose-go@65600ce.Adding report here rather than there because I'm observing and replicating the error from
compose
.Steps To Reproduce
Script to reproduce:
Result:
Removing
:ro
(the readonly mount option):Result:
And here's a successful interpolation if I don't extend and use a single yml:
Result:
Compose Version
Docker Environment
Anything else?
No response