As first proposed in #1377 I think it would be very useful to have a way to set a variable as required, and also set some default value.
web:
image: org/app:${VERSION?} # Required
Or
web:
image: org/app:${VERSION:latest} # Default Value
:+1:
:+1:
:+1: for defaults.
:+1:
:+1:
+1
:+1:
I'm working on a project where people have heterogeneous env, I'm working on OSX and some are using Ubuntu, when using docker-machine with virtualbox provider, I have to put the full path to make Volume works:
myservice:
volumes:
- ${HOST_VOLUME_PATH}/src:/src
The problem is now people who don't use virtualbox have to define the value, it should be great if we could have a default value:
myservice:
volumes:
- ${HOST_VOLUME_PATH:.}/src:/src
In other words :+1:
:+1:
:+1:
+1
:+1:
:+1:
:+1:
:+1:
This feature is a must have. Any devs from the docker-compsose team working on it ? If not I could propose a PR.
While having defaults would be really nice, we haven't decided on any implementations yet.
I (personally) think it's more likely we go with something like #2636 for default values. It supports more use-cases, and doesn't require us to invent new syntax for defaults.
I'd like to see the same implementation as https://docs.docker.com/engine/reference/builder/#environment-replacement Right now, I'd like the ability to switch from 2 different implementations for the log driver.
Given the following Base implementation:
intuitive-syslog:
log_driver: "syslog"
labels:
- net.c.d.datacenter: ${DATA_CENTER}
- net.c.d.env: ${NPMO_ENV}
- net.c.d.hostname: ${HOSTNAME}
- net.c.d.role: ${NPMO_ROLE}
intuitive-json:
log_driver: "json"
labels:
- net.c.d.datacenter: ${DATA_CENTER}
- net.c.d.env: ${NPMO_ENV}
- net.c.d.hostname: ${HOSTNAME}
- net.c.d.role: ${NPMO_ROLE}
I'd like to run the syslog driver by default and select the regular logs while debugging.
mycouch:
extends:
file: base.yml
service: intuitive-${LOG_DRIVER:-syslog}
build: roles/couchdb
restart: always
ports:
- "5984"
log_opt:
syslog-tag: "mycouch"
myredis:
extends:
file: base
service: intuitive-${LOG_DRIVER:-syslog}
image: redis
restart: always
expose:
- "6379"
log_opt:
syslog-tag: "myredis"
I'm getting the following error:
docker-compose -f services/new1.yml ps
ERROR: Invalid interpolation format for "extends" option in service "myredis": "intuitive-${LOG_DRIVER:-syslog}"
:+1: for both required and default values.
I actually believe variables should be required
by default but it might be too late for that now.
+1 - without this, the usefulness of variable expansion (which is a great feature) is severely limited
Just hit this problem again :(
$ docker-compose up
ERROR: Invalid interpolation format for "env_file" option in service "rabbitmq": "env/${DATA_CENTER:-aws}/${ENV:-dev}.env"
I agree with @matleh, without this in docker-compose, this is definitely useless...
Please please support the same features ALREADY SUPPORTED in Dockerfile https://docs.docker.com/engine/reference/builder/#environment-replacement
@aramalipoor Can you update the description of this issue to include the link to the currently supported variable interpolation as of Dockerfile?
thanks!
The section https://docs.docker.com/compose/compose-file/#variable-substitution describes that it is not supported... If this gets implemented, this documentation should be updated.
:+1:
馃憤
馃憤 to have this implemented the same way as in the Dockerfile implementation
:+1:
馃憤
Anyone got any news about this, it's been a whole 27 days since the last :+1: ?
Much much needed!
is there a PR already open with this change? Perhaps we need a volunteer to implement it.
Definitely need this...
There is no reason to not implement this...
+1
馃憤 +1
+1
Closing via #3108
:tada:
Most helpful comment
I'm working on a project where people have heterogeneous env, I'm working on OSX and some are using Ubuntu, when using docker-machine with virtualbox provider, I have to put the full path to make Volume works:
The problem is now people who don't use virtualbox have to define the value, it should be great if we could have a default value:
In other words :+1: