stewartie4
stewartie4

Reputation: 190

How can I natively load docker secrets mounted as a volume in spring boot

How can my spring boot application running inside a container access docker secrets mounted as a volume inside that same container?

Commonly suggested methods I DO NOT want to use:

Upvotes: 0

Views: 721

Answers (1)

stewartie4
stewartie4

Reputation: 190

Spring boot 2.4 introduced this feature as part of Volume mounted config trees using the spring.config.import property.
To read docker secrets mounted as a volume from the default location set:

spring.config.import = configtree:/run/secrets/

The property name will be derived from the secret filename and the value from the file contents. This can then be accessed like any other spring property.

Upvotes: 3

Related Questions