Compose: labels ignore environment variables

Created on 5 Aug 2019  路  2Comments  路  Source: docker/compose

Given:

services:
  foo:
    environment:
    - BAR=test
    labels:
    - foo=${BAR}

Will results in:

WARNING: The BAR variable is not set. Defaulting to a blank string.

Instead of expected: label foo=test, no warning

Most helpful comment

I know, but what's the reason for not implementing this ?

All 2 comments

The environment entry in the service refers to passing the BAR variable to the service, not to be used to interpolate in the compose file. For this, the BAR variable has to be present in the shell when running docker-compose, for example:

$ BAR=test docker-compose up

I know, but what's the reason for not implementing this ?

Was this page helpful?
0 / 5 - 0 ratings