Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Docker compose environment variable syntax #669

Merged
merged 3 commits into from
Oct 2, 2020

Conversation

areller
Copy link
Contributor

@areller areller commented Sep 21, 2020

This PR addresses this issue #657

  1. The env field in a service now accepts string of environment variables where the key and value are separated by a = sign.
  2. If an element in env is either missing a value key or is a string that misses a = sign, the value of the environment variable is taken from the operating system/shell.
  3. There is a new field under service, env_file which is a collection of strings which represent file paths. These file paths are formatted as explained in https://docs.docker.com/compose/env-file/

@areller
Copy link
Contributor Author

areller commented Sep 28, 2020

@jkotalik @davidfowl @JunTaoLuo any thoughts about this?

@davidfowl
Copy link
Member

davidfowl commented Sep 28, 2020

I like it! We used to have this but then we had the idea of config sources and changed the syntax.

var value = nodeValue.Substring(keyValueSeparator + 1)?.Trim();

config.Name = key;
config.Value = value?.Trim(new[] { ' ', '"' }) ?? string.Empty;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests for this case?

@davidfowl davidfowl merged commit 7a0b24c into dotnet:master Oct 2, 2020
@areller areller deleted the docker-compose-env-syntax branch October 5, 2020 01:15
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