Docker - how to dynamically configure an application that uses flat text config files?

10/29/2018

I'm ramping up on Docker and k8s, and am running into an issue with a 3rd party application I'm containerizing where the application is configured via flat text files, without override environment variables.

What is the best way to dynamically configure this app? I'm immediately leaning towards a sidecar container that accepts environment variables and writes the text file config, writes it to a shared volume in the pod, and then the application container will read the config file. Is this correct?

What is the best practice here?

-- user797963
docker
kubernetes

1 Answer

10/29/2018

Create a ConfigMap with this configuration file. Then, mount the ConfigMap into the pod. This will create the configuration file in mounted directory. Then, you can use this configuration file as usual.

Here are related example:

  1. Create ConfigMap from file.

  2. Mount ConfigMap as volume.

-- Emruz Hossain
Source: StackOverflow