Configuring Docker containers

02.12.2014
Joern Barthel

As readers of our blog know we've been avid users of Docker since, well, almost since it exists and have been adopting CoreOS for some of our production workloads for many months now. In 2015 we'll continue to closely follow the new developments (e.g. the new container runtime announced by CoreOS: Rocket) around the pattern we've adopted this year: deploying all of our new applications as containers.

Most of our apps follow the twelve-factor app manifesto and are configurable through environment variables alone. But there is also a plethora of legacy apps (like e.g. the member of the Atlassian toolchain family) and for them and every app caught in any state between those two philosophies we needed a solution to rewrite configuration files based on the value of certain environment variables.

Enter envplate

There are a few solutions for doing that, and in the past we've always favored the most simple: a wrapper script written in shell using sed -i to rewrite configuration files and calling exec to become the container process in the end.

Other solutions we've looked at include confd (which does a lot of things e.g. integrating with etcd or consul as well as adding real templating into the mix) and tiller (also adds external datasources, requires a Ruby VM to run). We always thought these solutions were doing either too much (and thus requiring us to adapt our software to them, not the other way around) or requiring dependencies we did not always want (like Ruby).

Our take on a solution for this problem - envplate (ep) - is a simpler thing.

Integrating ep into your Docker build can look as easy as this:

RUN curl -sLo /usr/local/bin/ep https://github.com/kreuzwerker/envplate/releases/download/v0.0.4/ep-linux && chmod +x /usr/local/bin/ep

...

CMD [ "/usr/local/bin/ep", "-v", "/etc/nginx/nginx.conf", "--", "/usr/sbin/nginx", "-c", "/etc/nginx/conf" ]

Hope you like it!

Joern Barthel

Joern entwickelt, debugged und entwirft Software seit über zehn Jahren. Bei den kreuzwerkern ist er für Architektur, neue Technologien und Konzepte zuständig. Das Interesse des Diplom-Informatikers gilt dem Einsatz von funktionalen Programmiersprachen und der Architektur…

Mehr Lesen ...
comments powered by Disqus