Description
Given the example compose file under "Steps To Reproduce", the result of running:
$ docker compose config --no-normalize --no-path-resolution example1
is:
name: demo
services:
example1:
container_name: example1
environment:
TZ: Australia/Sydney
image: example/example
ports:
- mode: ingress
target: 3000
published: "3001"
protocol: tcp
restart: unless-stopped
volumes:
- type: bind
source: ./volumes/example1/data
target: /var/lib/data
bind: {}
I have chosen:
--no-normalize because it removes references to networks; and
--no-path-resolution because it maintains project-relative external paths in volumes: clauses.
The output shows TZ with the value Australia/Sydney (from the .env file). My goal is that that should be displayed in its original form as TZ: ${TZ:-Etc/UTC}.
The --no-interpolate flag is defined as "Don't interpolate environment variables" and seems like a reasonable candidate for achieving this goal. The result of adding that flag is shown in the screen shot in the next section.
The --no-interpolate flag has achieved the expected result with respect to TZ but it has also produced a bunch of unexpected side effects, ranging from relatively unimportant through problematic, none of which would seem to have anything to do with environment variables.
For what I am trying to achieve, the most problematic difference is that the service definition for example2 has appeared in the output. This behaviour suggests that the presence of --no-interpolate causes config to ignore the [SERVICE...] argument.
I assume the name: demo (first line on the left hand side of the screen shot) is the project name. That line disappearing is actually beneficial for what I am trying to achieve but it isn't immediately clear what this has to do with environment variables.
The reverse-ordering of the last three lines of the ports: clause doesn't matter for my purposes. The same applies to the volumes: clause where the ordering and structural differences are just … strange.
Steps To Reproduce
-
Example compose file:
---
services:
example1:
container_name: example1
image: example/example
restart: unless-stopped
ports:
- "3001:3000"
environment:
TZ: ${TZ:-Etc/UTC}
volumes:
- ./volumes/example1/data:/var/lib/data
example2:
container_name: example2
image: example/example
restart: unless-stopped
ports:
- "3002:3000"
environment:
TZ: ${TZ:-Etc/UTC}
volumes:
- ./volumes/example2/data:/var/lib/data
...
-
Run:
$ diff -y \
<(docker compose config --no-normalize --no-path-resolution example1) \
<(docker compose config --no-normalize --no-path-resolution --no-interpolate example1)
-
The result is:
Compose Version
$ docker compose version
Docker Compose version v5.1.0
$ docker-compose version
Docker Compose version v5.1.0
Docker Environment
$ docker info
Client: Docker Engine - Community
Version: 29.2.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.31.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v5.1.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 6
Running: 6
Paused: 0
Stopped: 0
Images: 6
Server Version: 29.2.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: local
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: dea7da592f5d1d2b7755e3a161be07f43fad8f75
runc version: v1.3.4-0-gd6d73eb8
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.1.21-v8+
Operating System: Debian GNU/Linux 12 (bookworm)
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 3.704GiB
Name: sec-dev
ID: f6406dbb-2fc1-4834-9606-5e826871aec6
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false
Firewall Backend: iptables
Anything else?
Older cases raising issues with --no-interpolate (eg #13327, #12292, #12079, #11547) all seem to use examples where the compose file only contains a single service definition. While that scenario does show the unexpected re-ordering of clauses that would not seem to be related to environment variables, it won't reveal the issue with the [SERVICE...] argument being ignored.
Description
Given the example compose file under "Steps To Reproduce", the result of running:
$ docker compose config --no-normalize --no-path-resolution example1is:
I have chosen:
--no-normalizebecause it removes references to networks; and--no-path-resolutionbecause it maintains project-relative external paths involumes:clauses.The output shows
TZwith the valueAustralia/Sydney(from the.envfile). My goal is that that should be displayed in its original form asTZ: ${TZ:-Etc/UTC}.The
--no-interpolateflag is defined as "Don't interpolate environment variables" and seems like a reasonable candidate for achieving this goal. The result of adding that flag is shown in the screen shot in the next section.The
--no-interpolateflag has achieved the expected result with respect toTZbut it has also produced a bunch of unexpected side effects, ranging from relatively unimportant through problematic, none of which would seem to have anything to do with environment variables.For what I am trying to achieve, the most problematic difference is that the service definition for
example2has appeared in the output. This behaviour suggests that the presence of--no-interpolatecausesconfigto ignore the[SERVICE...]argument.I assume the
name: demo(first line on the left hand side of the screen shot) is the project name. That line disappearing is actually beneficial for what I am trying to achieve but it isn't immediately clear what this has to do with environment variables.The reverse-ordering of the last three lines of the
ports:clause doesn't matter for my purposes. The same applies to thevolumes:clause where the ordering and structural differences are just … strange.Steps To Reproduce
Example compose file:
Run:
The result is:
Compose Version
Docker Environment
Anything else?
Older cases raising issues with
--no-interpolate(eg #13327, #12292, #12079, #11547) all seem to use examples where the compose file only contains a single service definition. While that scenario does show the unexpected re-ordering of clauses that would not seem to be related to environment variables, it won't reveal the issue with the[SERVICE...]argument being ignored.