[BUG] Environment variable interpolation not remove double quote
in value when using environment config array #12418
Closed as not planned
Description
Description
services:
rdbms1:
image: postgres:17.2-alpine
environment:
# THIS WORKS
POSTGRES_USER: "${POSTGRES_USER:-foo}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-bar}"
rdbms2:
image: postgres:17.2-alpine
environment:
# THIS FAILS
- POSTGRES_USER="${POSTGRES_USER:-foo}"
- POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-bar}"
when using environment config array like in service rdbms2 above, the double quote is not removed after parsing variable value, but when using environment config map doesn't happen
Steps To Reproduce
- Run:
docker compose -f - up <<EOF
services:
rdbms1:
image: postgres:17.2-alpine
environment:
POSTGRES_USER: "${POSTGRES_USER:-foo}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-bar}"
rdbms2:
image: postgres:17.2-alpine
environment:
- POSTGRES_USER="${POSTGRES_USER:-foo}"
- POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-bar}"
EOF
- You got:
rdbms2-1 | 2024-12-21 08:09:10.069 UTC [35] FATAL: zero-length delimited identifier at or near """" at character 12
rdbms2-1 | 2024-12-21 08:09:10.069 UTC [35] STATEMENT: ALTER USER ""foo"" WITH PASSWORD E'"bar"';
rdbms2-1 |
rdbms2-1 | child process exited with exit code 1
service 1 ok, but service 2 fail because the password value have double quote
Compose Version
Docker Compose version v2.31.0
Docker Environment
Client: Docker Engine - Community
Version: 27.4.0
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.19.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.31.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 10
Running: 9
Paused: 0
Stopped: 1
Images: 47
Server Version: 27.4.0
Storage Driver: overlayfs
driver-type: io.containerd.snapshotter.v1
Logging Driver: json-file
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
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc version: v1.2.2-0-g7cb3632
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.153.1-microsoft-standard-WSL2
Operating System: Debian GNU/Linux 12 (bookworm)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.792GiB
Name: foo-laptop
ID: b2b48662-aae9-415d-ad86-52e27957892a
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response