Defining a boolean in a docker-compose.yml file:
environment:
SOME_VAR: true
and running docker up
results in:
contains true, which is an invalid type, it should be a string, number, or a null
Attempts to solve the issue
- If true is changed to True the issue persists.
Using
'true'
is not accepted by the code itself (a play framework app is started using the./target/universal/stage/bin/APPNAME -Dplay.evolutions.db.default.autoApply=
, i.e. either-Dplay.evolutions.db.default.autoApply=true
or-Dplay.evolutions.db.default.autoApply=false
parameter):VAR has type STRING rather than BOOLEAN
Using
yes
orno
as a variable results in:contains true, which is an invalid type, it should be a string, number, or a null
Using
yes
and using a script that transformsyes
to true works
Discussion
According the docs Any boolean values; true, false, yes no, need to be enclosed in quotes to ensure they are not converted to True or False by the YML parser
:
Environment
Add environment variables. You can use either an array or a dictionary. Any boolean values; true, false, yes no, need to be enclosed in quotes to ensure they are not converted to True or False by the YML parser.
Environment variables with only a key are resolved to their values on the machine Compose is running on, which can be helpful for secret or host-specific values.
environment: RACK_ENV: development SHOW: 'true' SESSION_SECRET: environment: - RACK_ENV=development - SHOW=true - SESSION_SECRET
Question
Why is it not allowed?
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure
SOME_VAR: "true"
orSOME_VAR: 1
if this works for you