How to idiomatically access sensitive data when building a Docker image?

Regarding idiomatic approach, I’m not sure, although docker is still quite young to have too many idioms about.

We have had this same issue at our company, however. We have come to the following conclusions, although these are our best efforts rather than established docker best practices.

1) If you need the values at build time: Supply a properties file in the build context with the values that can be read at build, then the properties file can be deleted after build. This isn’t as portable but will do the job.

2) If you need the values at run time: Pass values as environment variables. They will be visible to someone who has access to ps on the box, but this can be restricted via SELinux or other methods (honestly, I don’t know this process, I’m a developer and the operations teams will deal with that part).

Leave a Comment