Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Variable interpolation failing #12449

Open
thehale opened this issue Jan 10, 2025 · 0 comments
Open

[BUG] Variable interpolation failing #12449

thehale opened this issue Jan 10, 2025 · 0 comments

Comments

@thehale
Copy link

thehale commented Jan 10, 2025

Description

On Ubuntu in DistroBox on Fedora, my docker compose configurations are not interpolating variables found in the shell environment for the docker compose command. I'd expect shell variables to be interpolated into the docker compose configuration.

The reproduction below is a minimal example to exemplify the issue. In my full usage, the Makefile has over a dozen targets each serving as a different bundle of command-level shell variables to apply to my docker compose configuration (make test >> 0.5kb of test commands). The "command-level" piece is important so that running one make target doesn't modify the shell environment used by other targets.

Interpolation works as expected on a different device running Ubuntu in WSL2 on Windows 11.

Steps To Reproduce

docker-compose.yml

services:
  sample:
    image: ubuntu
    environment:
      - LOOK_AT_ME=${LOOK_AT_ME:-default in compose file}
    command: printenv

Makefile

test:
	@echo "------------ENV for docker compose--------------"
	@LOOK_AT_ME="value from makefile" \
		printenv | grep LOOK_AT_ME
	@echo "------------CONFIG of docker compose--------------"
	@LOOK_AT_ME="value from makefile" \
		docker compose config
	@echo "------------OUTPUT of docker compose--------------"
	@LOOK_AT_ME="value from makefile" \
		docker compose up

❌ Broken Example - Ubuntu in DistroBox on Fedora

$ make test
------------ENV for docker compose--------------
LOOK_AT_ME=value from makefile                               <--- ✅ Looks good
------------CONFIG of docker compose--------------
name: test
services:
  sample:
    command:
      - printenv
    environment:
      LOOK_AT_ME: default in compose file                    <--- ❌ Undesired
    image: ubuntu
    networks:
      default: null
networks:
  default:
    name: test_default
------------OUTPUT of docker compose--------------
[+] Running 1/1
 ✔ Container test-sample-1  Recreated                                                                                                                                 0.3s 
Attaching to sample-1
sample-1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sample-1  | HOSTNAME=43cd10a1d562
sample-1  | LOOK_AT_ME=default in compose file               <--- ❌ Undesired
sample-1  | HOME=/root
sample-1 exited with code 0

✅ Working Example - Ubuntu in WSL2 on Windows 11

$ make test
------------ENV for docker compose--------------
LOOK_AT_ME=value from makefile                               <--- ✅ Looks good
------------CONFIG of docker compose--------------
name: docker-compose-bug-demo
services:
  sample:
    command:
      - printenv
    environment:
      LOOK_AT_ME: value from makefile                        <--- ✅ Looks good
    image: ubuntu
    networks:
      default: null
networks:
  default:
    name: docker-compose-bug-demo_default
------------OUTPUT of docker compose--------------
[+] Running 1/0
 ✔ Container docker-compose-bug-demo-sample-1  Created                                                                                                                                              0.0s 
Attaching to sample-1
sample-1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sample-1  | HOSTNAME=c44bfe42ea68
sample-1  | LOOK_AT_ME=value from makefile                   <--- ✅ Looks good
sample-1  | HOME=/root
sample-1 exited with code 0

Compose Version

**❌ Broken Example - Ubuntu in DistroBox on Fedora**

$ docker compose version
Docker Compose version v2.32.1

$ docker-compose version
# no output


**✅ Working Example - Ubuntu in WSL2 on Windows 11**


$ docker compose version
Docker Compose version v2.32.1

$ docker-compose version
zsh: command not found: docker-compose

Docker Environment

**❌ Broken Example - Ubuntu in DistroBox on Fedora**

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

Server:
 Containers: 11
  Running: 6
  Paused: 0
  Stopped: 5
 Images: 13
 Server Version: 27.4.1
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  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: runc io.containerd.runc.v2
 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: 6.11.8-300.fc41.x86_64
 Operating System: Aurora 41 (FROM Fedora Kinoite)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.27GiB
 Name: REDACTED
 ID: 5d17c927-6b42-44c5-89ad-41b568f5ecac
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: REDACTED
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false


**✅ Working Example - Ubuntu in WSL2 on Windows 11**

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

Server:
 Containers: 20
  Running: 0
  Paused: 0
  Stopped: 20
 Images: 38
 Server Version: 27.4.1
 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: cgroupfs
 Cgroup Version: 1
 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: 57f17b0a6295a39009d861b89e3b3b87b005ca27
 runc version: v1.1.14-0-g2c9f560
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.167.4-microsoft-standard-WSL2
 Operating System: Ubuntu 24.04.1 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.623GiB
 Name: REDACTED
 ID: b3cf2378-9bab-4745-b1ec-d1618e71f3c0
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: REDACTED
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Anything else?

Additional system information that may be relevant.

❌ Broken Example - Ubuntu in DistroBox on Fedora

$ uname --all
Linux HOSTNAME_REDACTED 6.11.8-300.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 14 20:37:39 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -d
No LSB modules are available.
Description: Ubuntu 24.04.1 LTS

✅ Working Example - Ubuntu in WSL2 on Windows 11

$ uname --all
Linux HOSTNAME_REDACTED 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -d
No LSB modules are available.
Description:    Ubuntu 24.04.1 LTS

I'm happy to provide additional context and debugging info as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant