Skip to content

Regression: newline in quoted string for .env broken #8626

@tracker1

Description

@tracker1

Description of the issue

When importing a .env file with a quoted string, containing a new-line character (multi-line environment variable), it is broken in 2.x (v2.0.0-rc.3), this is working correctly in 1.x (1.29.2)

Context information (for bug reports)

docker-compose.yml

version: "3.3"
services:
  test:
    image: alpine
    command: 'echo "hello $FOO!"'

.env

FOO="foo
bar
baz"

Docker Version

❯ docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:54:02 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output - Using Compose V1 (Working)

❯ docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

❯ docker-compose config
services:
  test:
    command: 'echo "hello foo

      bar

      baz !"'
    image: alpine
version: '3.3'

❯ docker-compose up
Starting dc1_test_1 ... done
Attaching to dc1_test_1
test_1  | hello foo
test_1  | bar
test_1  | baz !
dc1_test_1 exited with code 0

Output - Using Compose V2 (Broken)

❯ docker compose version
Docker Compose version v2.0.0-rc.3

❯ docker compose config
invalid variable name "baz\""

❯ docker compose up
invalid variable name "baz\""

Additional information

  • OS; Ubuntu 20.04.2 LTS on Windows 10 x86_64
  • Kernel: 5.4.72-microsoft-standard-WSL2
  • Installation: Docker Desktop for Windows with WSL2 integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions