docker / compose

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

Reduced test case: Compose .env unexpected character error #8964

Closed joemaller closed 2 years ago

joemaller commented 2 years ago

Description

This issue is a reduced test case: docker compose throws errors on some .env files which prevents containers from running. The same .env files work correctly in versions of prior versions of docker-compose (pre v2).

Related to #7624, #8879 & #8763

Steps to reproduce the issue:

  1. In a clean directory, create a .env file containing the following:
    TEST_VALUE=ssh user@host
  2. Create a docker-compose.yml file containing the following:
    services:
     env:
       image: bash
       environment:
          - TEST_VALUE
       command: env
  3. run docker-compose config (works)
  4. run docker compose config (error)

note: Use Docker Compose V2 must be unchecked in Docker's General Preferences to access the old docker-compose binary.

Describe the results you received:

docker compose config throws this error: unexpected character "@" in variable name near "user@host\n"

Describe the results you expected:

.env file is parsed, containers run normally, same input/output as docker-compose pre-v2.

Additional information you deem important (e.g. issue happens only occasionally):

The .env file validates without errors using python-dotenv and Rust's dotenv-linter, and can be loaded by the dotenv node.js package, with or without quoting the value.

Running docker-compose up shows the environment including the value from .env. If the .env value is quoted, both docker compose up and docker-compose up return identical results. The property's value should not need quotes.

The reported errors were reproduced on WSL2 and macOS.

Output of docker compose version:

Docker Compose version v2.1.1

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.3)
  compose: Docker Compose (Docker Inc., v2.1.1)
  scan: Docker Scan (Docker Inc., 0.9.0)

Server:
 Containers: 30
  Running: 3
  Paused: 0
  Stopped: 27
 Images: 11
 Server Version: 20.10.10
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 5b46e404f6b9f661a205e28d59c982d3634148f8
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.60.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.688GiB
 Name: docker-desktop
 ID: QQVC:QBGP:2OID:BTLI:3PGY:WEMN:KFE6:R5FO:HUEE:74MF:AETV:HI3N
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Use Docker Compose V2 is unchecked in Docker's General Preferences, docker-compose --version returns

docker-compose version 1.29.2, build 5becea4c
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed because it had not recent activity during the stale period.