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] Escape character appears in final value when escaping single quotes in environment file #11276

Closed
aidaneastcott opened this issue Dec 14, 2023 · 0 comments · Fixed by compose-spec/compose-go#511

Comments

@aidaneastcott
Copy link

Description

The environment file syntax documentation contains the following example:

  • Quotes can be escaped with \.
    • VAR='Let\'s go!' -> Let's go!

Source: https://docs.docker.com/compose/environment-variables/env-file/

However, when I attempt this, VAR has a value of Let\'s go!.

Steps To Reproduce

  1. Create an environment file as follows:
# test.env
VAR='Let\'s go!'
  1. Create a Compose file as follows:
# compose.yaml
services:
  test:
    image: debian
    env_file: test.env
    command: env
  1. Run docker compose up

This is the output I get:

scratch-test-1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
scratch-test-1  | HOSTNAME=ef2eaa14b918
scratch-test-1  | VAR=Let\'s go!
scratch-test-1  | HOME=/root
scratch-test-1 exited with code 0

This is the expected output:

scratch-test-1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
scratch-test-1  | HOSTNAME=ef2eaa14b918
scratch-test-1  | VAR=Let's go!
scratch-test-1  | HOME=/root
scratch-test-1 exited with code 0

Compose Version

Docker Compose version v2.21.0

Docker Environment

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

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 3
 Server Version: 24.0.7
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dd1e886e55dd695541fdcd67420c2888645a495
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.133.1-microsoft-standard-WSL2
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.731GiB
 Name: [REDACTED]
 ID: 8020fa55-64b4-46e1-8b70-947218f6c476
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 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?

No response

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

Successfully merging a pull request may close this issue.

1 participant