Our team avoids putting credentials in repositories, so that means they're not allowed in Dockerfile
. Our best practice within applications is to use creds from environment variables.
We solve for this using docker-compose
.
Within docker-compose.yml
, you can specify a file that contains the environment variables for the container:
env_file:
- .env
Make sure to add .env
to .gitignore
, then set the credentials within the .env
file like:
SOME_USERNAME=myUser
SOME_PWD_VAR=myPwd
Store the .env
file locally or in a secure location where the rest of the team can grab it.
See: https://docs.docker.com/compose/environment-variables/#/the-env-file