How would I set "spring.datasource.password" using a docker secret? How would I set "spring.datasource.password" using a docker secret? docker docker

How would I set "spring.datasource.password" using a docker secret?


With the help of a customized implementation of the EnvironmentPostProcessor interface, the "spring.datasource.password" can be set as following in application.yml

   spring:     datasource:       password: ${docker-secret-my-db-passwd}

The docker secrets bind within the container are presented as files under the /run/secrets folder. The EnvironmentPostProcessor implementation load these file as the environment properties.

The idea has also been introduced in Spring boot reference - Encrypted Properties