Compose: .env file multiline strings

Created on 16 Jun 2016  路  6Comments  路  Source: docker/compose

In docker-compose.yml file I've:

    LETSENCRYPT_HOST: |
          abc.domain.com,
          abe.domain.com,
          aba.domain.com

I'd like to move this to .env file, is this possible?

docs say

Compose expects each line in an env file to be in VAR=VAL format

Most helpful comment

No it is not a duplicate of 3527.

This is multline support:

COMPOSE_FILE=php.yml:\
mysql.yml

This is support for newlines:
HOST="domain1.com,ndomain2.com"

All 6 comments

Hi,

This is a duplicate of #3527 :)

No it is not a duplicate of 3527.

This is multline support:

COMPOSE_FILE=php.yml:\
mysql.yml

This is support for newlines:
HOST="domain1.com,ndomain2.com"

this solved already?

Hi,
This is still unchanged.
Does anybody know a suitable workaround?, it would be nice to avoid storing e.g. GitLab omnibus configuration directly in docker-compose files, so that the compose configuration could be managed by version control.
Thanks in advance!
PS: @shin- Can you please re-open this issue, because like @keithy mentioned the multiline variable values are something different. I tried to set the GITLAB_OMNIBUS_CONFIG property via a multiline variable manually through a bash script ( using a custom entrypoint ) but unfortunately this was ignored by the GitLab container ( and the solution was quite ugly anyway ).

I have a script: docker-compose-use <a.env> <b.env>
This script just processes readable a.env and b.env into a single .env file, by removing comments and supporting newlines. It is that simple.

It works really well, and is the basis of my angelbox docker toolkit.

The idea of angelbox is that any docker image can be packaged as a single docker-compose service in which all of the relevant parameters are broken out into environment variables.

Then you provide your configuration as two files, one defining the services that you want composed, the other providing parameters specific to that deployment scenario (i.e. per server). Thus far this works for every scenario that I can envisage.

https://github.com/keithy/sprankle-pod

according to the document: https://docs.docker.com/compose/compose-file/#environment
you can define envs in compose file like this

~
environment:
RACK_ENV: development
SHOW: 'true'
SESSION_SECRET: |
new line 1
new line 2
~

Was this page helpful?
0 / 5 - 0 ratings