Read environment variables from files in bash

In the Docker world it’s increasingly common to send secrets through files instead of environment variables by appendingĀ _FILE to the regular environment variable name.

Here’s a bash function which reads such files and updates the corresponding environment variable with the file contents.

Example usage:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.