Externalising Spring Boot properties when deploying to Docker

前端 未结 6 1945
天命终不由人
天命终不由人 2020-12-01 04:20

In my Spring Boot app I want to externalise the properties to run in a Docker container. When first deployed, the properties that are currently in my-server/src/main/

6条回答
  •  渐次进展
    2020-12-01 04:53

    Your approach is definitely a viable solution, however it is not recommended, since it makes your image not portable between different production and dev environments. Containers should be immutable and all environment configuration should be externalized.

    For spring boot, there is very powerful project that allows you to externalize configuration. Its called Spring Cloud Config. The config server allows you to save your environment specific configuration in a git repository and serve the configuration to applications that need it. You basically just save the same application.yml in git and point the config server to the repository location.

    Following this approach you can define multiple configuration files for different environments and keep your docker container immutable.

提交回复
热议问题