I have a scala sbt application and have a default application.conf.
I built a docker image to run this application via docker.
How can I replace the default application.conf
in the docker container at a run time?
Asked
Active
Viewed 1.2k times
8

vkt
- 1,401
- 2
- 20
- 46
1 Answers
7
I'd recommend instead of passing application.conf
file with overrides, go with overrides based on environment variables, because of reasons like:
- Mounting volume with configuration file might be tricky from deployment tools perspective;
- Not all configurations management tools (for instance HashiCorp Consul) provide HOCON support, but managing environment variables is almost a standard. Especially if it contains secrets which needs to be protected;
So, you can do next: In your application conf set overrides via environment variable:
foo=default
foo={?FOO}
And run application docker container with specific override:
docker run ...
-e foo=bar \
...
Please, see for more details:
- HOCON
Optional system or env variable overrides
: https://github.com/lightbend/config#optional-system-or-env-variable-overrides - Run docker container with environment variables: https://docs.docker.com/engine/reference/run/#env-environment-variables
Hope this helps!

Ivan Kurchenko
- 4,043
- 1
- 11
- 28