-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Description
I've been experimenting with override files and, in particular, the "reset value" feature described at:
I'm not sure it's working as intended. Here's a summary of my testing:
Steps To Reproduce
Assume the project directory contains a .env file with the line:
TZ=Australia/Sydney
I'm not using TZ for any particular reason other than the service definitions I was working with already had TZ defined such that it would search .env then apply Etc/UTC as a failsafe.
Four tests:
-
Compose file for a service contains hyphen-style syntax:
environment: - TZ=${TZ:-Etc/UTC}
Override file contains matching hyphen-style syntax:
environment: - TZ=!reset null
Result from running
docker configon the service:environment: TZ: '!reset null'
and that value gets passed into the container (useless as a TZ).
-
Compose file for a service contains hyphen-style syntax:
environment: - TZ=${TZ:-Etc/UTC}
Override file contains non-matching colon-style syntax:
environment: TZ: !reset null
Result from running
docker configon the service:environment: TZ: Australia/Sydney
and that value gets passed into the container (valid as a TZ but not what was wanted).
-
Compose file for a service contains colon-style syntax:
environment: TZ: ${TZ:-Etc/UTC}
Override file contains non-matching hyphen-style syntax:
environment: - TZ=!reset null
Result from running
docker configon the service:environment: TZ: '!reset null'
and that value gets passed into the container (useless as a TZ).
-
Compose file for a service contains colon-style syntax:
environment: TZ: ${TZ:-Etc/UTC}
Override file contains matching colon-style syntax:
environment: TZ: !reset null
Result from running
docker configon the service is no environment section. The container does not get TZ passed into the container. This is the expected result of all four tests.
Compose Version
$ docker compose version
Docker Compose version v5.0.2
$ docker-compose version
Docker Compose version v5.0.2
Docker Environment
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.0.2
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:
127.0.0.0/8
::1/128
Live Restore Enabled: false
Firewall Backend: iptables
Anything else?
The FOO: example in the documentation uses colon-style syntax and doesn't explicitly rule out hyphen-style syntax. There are a lot of service definitions out there in the big wide world that use hyphen-style syntax so they should probably be supported, irrespective of whether they use matching or mismatching syntax between the compose and override files.
Test 3 is quite intriguing because the value of Australia/Sydney which can only have come from the .env file looks like it is somehow bypassing the override.
I have not experiments with !override or ![reset] forms, nor explored what happens with other hyphen-style clauses (eg depends_on:).