Dockerfile Surprise

Tomas Ekeli
Dolittle
Published in
1 min readAug 16, 2018
By Alex E. Proimos (https://www.flickr.com/photos/proimos/4199675334/) [CC BY 2.0 (https://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

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.

--

--