user797963
user797963

Reputation: 3037

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

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?

Upvotes: 1

Views: 466

Answers (1)

Emruz Hossain
Emruz Hossain

Reputation: 5568

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.

Upvotes: 3

Related Questions