Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Support inherited environment variable not found with multiple vars #12

Closed
wants to merge 1 commit into from
Closed

Support inherited environment variable not found with multiple vars #12

wants to merge 1 commit into from

Conversation

flemay
Copy link

@flemay flemay commented Dec 1, 2021

Hi!

I have been testing the command docker compose with environment variable files and the result differs from Docker and Docker-Compose.

TL;DR

Inherited environment variable not found is already implemented but does not work when there are other env vars defined. This PR fixes it. :)

Test

Define a .env file with the following:

ENV_A
ENV_B=
ENV_C=env_c

And a docker-compose.yml file:

services:
  alpine:
    image: alpine
    env_file: .env

Docker

$ docker run --rm --env-file=.env alpine env
ENV_B=
ENV_C=env_c

Here ENV_A has not been set and ENV_B is set with an empty value.

Docker-Compose

$ docker-compose run --rm alpine env
ENV_B=
ENV_C=env_c

With Docker-Compose, we get the same outcome as Docker

Compose

$ docker compose run --rm alpine env
ENV_C=env_c
ENV_A=ENV_B=

Here's where the outcome is quite unexpected: ENV_A is set with the value ENV_B=.

Compose seems to have a problem with key-only items in .env file.

Fix

After investigation, I ended up finding the issue with godotenv which is used by compose-go and docker compose. So I decided to create this PR to fix the compatibility issue.

@ndeloof
Copy link
Collaborator

ndeloof commented Jan 12, 2022

Hi.
We have merged godotenv into compose-go by compose-spec/compose-go#215
Could you please apply this pull-request to this repository?

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

Successfully merging this pull request may close these issues.

2 participants