Version:
docker-compose version 1.11.2, build dfed245
I want to set the environment variable VAR1 in the compose file to an empty string, rather than having it unset.
````
version: '2'
services:
srv1:
image: myimagename
environment:
However, with this setting in the docker compose file the variable VAR1 turns out to be unset once I run the container.
- VAR1=""
then the value of VAR1 inside the container is ""
- VAR1=${UNSET}
then VAR1 inside the container is unset- VAR1: ${UNSET}
I get the error services.rec.environment contains {"VAR1": ""}, which is an invalid type, it should be a string
Thus: how to assign an empty string to a variable in docker-compose?
Found the problem - error in the shell script - close.
@bergtwvd How do you set ENV as empty?
so how did you do it?
Update: here's a hack: ENV EMPTY_VAR ${1:+1}
from https://docs.docker.com/engine/reference/builder/#environment-replacement
Most helpful comment
@bergtwvd How do you set ENV as empty?