docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.54k stars 5.17k forks source link

[BUG] Double-dollar sign not working anymore for literal dollar sign in command string #12005

Open Emulator000 opened 1 month ago

Emulator000 commented 1 month ago

Description

According to the Docker Compose documentation, using a double-dollar sign ($$) should allow for a literal dollar sign and prevent Docker Compose from interpolating the value. This feature is crucial for referring to environment variables within the command string that should not be processed by Docker Compose itself.

From the Docker Compose documentation:

You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign. This also prevents Compose from interpolating a value, so a $$ allows you to refer to environment variables that you don't want processed by Compose.

web: build: . command: "$$VAR_NOT_INTERPOLATED_BY_COMPOSE"

Problem

In my compose.yaml file, I am attempting to use $$CONSOLE_CONFIG_FILE to ensure that the environment variable is passed as a literal string to the container’s shell. However, despite following the documented approach, Docker Compose still tries to interpolate the environment variable, leading to the following warning in the logs:

WARN[0000] The "CONSOLE_CONFIG_FILE" variable is not set. Defaulting to a blank string.

This behavior indicates that the double-dollar sign mechanism to prevent interpolation is no longer working as intended.

Steps To Reproduce

  1. Create a compose.yaml file with a service using a double-dollar sign to prevent interpolation;
  2. Observe the logs and notice that Docker Compose attempts to interpolate the variable despite the double-dollar sign.

Compose Version

Docker Compose version v2.29.0

Docker Environment

Client: Docker Engine - Community
 Version:    27.1.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 15
  Running: 9
  Paused: 0
  Stopped: 6
 Images: 15
 Server Version: 27.1.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 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: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-1010-gcp
 Operating System: Ubuntu 24.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 61.85GiB
 Name: **************
 ID: **************
 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

Emulator000 commented 1 month ago

Using four ($$$$) dollar sign temporarily solves the issue.

accforgithubtest commented 1 month ago

LOL - using four ($$$$) dollar sign works !

Wild that that this double dollar "issue" has been open for so long, and now out of nowhere we need four dollar signs.

zaggash commented 1 month ago

I agree I have multiple compose file that worked on v2.28.1 using $$ interpolation inline. Now they are failing in v2.29.0.

Going back to v2.28.1 waiting for a fix.

jhrotko commented 1 month ago

This is a known issue with version v2.29.0. It is working in v2.28.1. We will release a fix soon. Relates #11990