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=trueor-Dplay.evolutions.db.default.autoApply=falseparameter):VAR has type STRING rather than BOOLEAN
Using
yesornoas a variable results in:contains true, which is an invalid type, it should be a string, number, or a null
Using
yesand using a script that transformsyesto 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?