Bug #86981 Docker image on/off flags are read as on if nonempty, otherwise false
Submitted: 7 Jul 2017 8:53 Modified: 26 Sep 2017 5:41
Reporter: Lars Tangvald Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Package Repos Severity:S3 (Non-critical)
Version:1.0.0 OS:Any
Assigned to: Lars Tangvald CPU Architecture:Any

[7 Jul 2017 8:53] Lars Tangvald
Description:
On/off flags in the image, such as MYSQL_RANDOM_ROOT_PASSWORD are simply seen as "on" if they have nonzero length (-z test in bash), so specifying it without value turns it off, and setting a "false" value of will set it on.

How to repeat:
* run: docker run -e MYSQL_RANDOM_ROOT_PASSWORD mysql/mysql-server
* Observe failure because MYSQL_RANDOM_ROOT_PASSWORD is not specified

Suggested fix:
bash 4.2 added the -v test to check simply if an environment variable is set, whether it is empty or not.
Should simply be to use that instead.
[26 Sep 2017 5:41] Lars Tangvald
Posted by developer:
 
The only way to fix this fully would be to a) Add a slightly hacky way of making an empty but set environment variable evaluate to true, and b) Including a full list of strings to interpret as true/false, since there's no inbuilt functionality for this in bash.
This would add unwanted complexity to the scripts, so we've instead noted the issue in the documentation at https://dev.mysql.com/doc/refman/5.7/en/docker-mysql-more-topics.html