Dockerfile Surprise
I discovered what I’d call a bug in our configuration of a docker today. We are using environment variables to configure stuff and baking that into the docker images by setting it in the .Dockerfile.
The pattern is like this:
FROM {base_image}
ENV environment_variable_a="the value of a when running"
ENV environment_variable_b="the value of b when running"
Simple, right? Yeah, but I’d made a mistake. My .Dockerfile looked like this:
FROM {base_image}
ENV environment_variable_a = "value of a when running"
ENV environment_variable_b = "value of b when running"
Do you see the mistake? I only caught it once I actually output to the console what the environment variables where on running the docker. “environment_variable_a” was actually “= value of a when running”!
Lesson learned: You’re not allowed spaces around the assignment operator in dockerfiles.
Better lesson learned: Double-check what the variables actually are at run-time somehow.