How can we provide application.properties
to spring boot app in a docker? Would normally copying the application.properties
to the container work?

- 1,493
- 6
- 23
- 34

- 81
- 4
-
See [Spring Cloud Config Server](https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html) – Oct 10 '19 at 05:56
3 Answers
you can keep that file at some location and map that location to volume. It will connect the local machine to docker container's world
Refer this

- 2,044
- 1
- 7
- 18
I suggest you build the Image with properties included. If needed, add a startscript and provide environment variables per stage (dev, qa, prod), which symlink the needed files.

- 657
- 4
- 8
-
It is already built with the application.properties. But i want to change them when I'm deploying the application on separate servers – nuwan karunarathna Oct 10 '19 at 05:00
-
The answer to this will be widely opinionated, some folks like to mount the file as a volume while other like to substitute the required configuration by reading it from environment variables through a shell script that is run as the entrypoint of the docker container.
Although if you're using Spring, it allows externalized configuration which can be taken from multiple sources. One of the sources is the environment variables that directly override the default configuration.
The approach I take though is to provide them as command line arguments to the JVM command by making the JVM command the entrypoint and providing the arguments at the end of the docker run command

- 101
- 2
- 5