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

Unable to parse the docker-compose.yml with env var. #2676

Closed
1 task
pratikid opened this issue Aug 9, 2020 · 2 comments
Closed
1 task

Unable to parse the docker-compose.yml with env var. #2676

pratikid opened this issue Aug 9, 2020 · 2 comments

Comments

@pratikid
Copy link

pratikid commented Aug 9, 2020

Description:

Error is generated while trying to parse docker-compose.yml along with environment variables.

We are using certain components of laradock to run containers with required components. To keep the yaml file up-to-date with the repository, we tried to parse docker-compose.yml with Symfony Yaml components for further modification.

Laravel code for parsing yaml:

use Symfony\Component\Yaml\Yaml;

$value = Yaml::parseFile('docker-compose.yml');
dd($value);

After executing above code below output is obtained:
OUTPUT

^ array:4 [▼
  "version" => "3"
  "networks" => array:2 [▶]
  "volumes" => array:23 [▶]
  "services" => array:85 [▶]
]

Further steps:

  1. We renamed env-example to .env
  2. Stored the output of docker-compose config to docker-compose.yml
    • docker-compose config command display output of yaml file with environment variables loaded.
    docker-compose config > docker-compose.yml
  3. Tried to parse the docker-compose.yml again with environment variables loaded. [Generated Error]

Expected Behavior:

Output as mentioned above, along with the environment variables loaded inside array.

Context information:

Output of git rev-parse HEAD

9d68a48c3e22f83520acb1cd4c72de9dcf7e91fb

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.9
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        9d988398e7
 Built:             Fri May 15 00:25:27 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.9
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       9d988398e7
  Built:            Fri May 15 00:24:05 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose version

docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

System info: CentOS 7

Kernel release: 3.10.0-1062.18.1.el7.x86_64
Architecture: x86_64
Operating System: CentOS Linux release 7.7.1908 (Core)

Steps to reproduce the issue:

Basic Laravel setup with Yaml Component to parse docker-compose.yml with the environment loaded.

  1. Configure Laravel/Symfony framework with Yaml Component(Symfony).
  2. Keep docker-compose.yml and env-example(renamed to .env) in the same directory.
  3. Execute docker-compose config and store the output in another yaml file "docker-compose.yml".
  4. Parse file using Yaml Component.
    use Symfony\Component\Yaml\Yaml;
    dd(Yaml::parseFile('docker-compose.yml'));
  5. Error generated:
    Unable to parse the YAML string: Malformed inline YAML string: "'external_url ''http://localhost''" at line 277 (near "GITLAB_OMNIBUS_CONFIG: 'external_url ''http://localhost''").

Additional info:

PFA docker-compose.yml (environment var loaded)
docker-compose.yml.txt

  • Parse the docker-compose.yml file along with the environment variables into a PHP or other lang object.
    This will generate error near loading environment variable GITLAB_OMNIBUS_CONFIG
@stale
Copy link

stale bot commented Nov 7, 2020

Hi 👋 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 stale bot added the Stale label Nov 7, 2020
@stale
Copy link

stale bot commented Nov 28, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Nov 28, 2020
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