The 12 Factor way, is a general guideline that provides best practices when building applications. One of them is using environment variables to store application configuration.
What will we be doing:
In this post we will build a simple docker application that returns the environment variable’s value to standard out. We are using environment substitution, so if the environment variable is not provided, we will set a default value of
We will have the environment variable
OWNER and when no value is set for that Environment Variable, the
NOT_DEFINED value will be returned.
1 2 3
Building the image:
Putting it to action:
Now we will run a container and pass the
OWNER environment variable as an option:
When we run a container without specifying the environment variable: