Skip to content

Procedure for working with passwords in Docker AWS

Jo Cook edited this page Jan 28, 2021 · 2 revisions

Rather than including passwords for (eg) connecting to postgresql in the docker config, we're using a .env file to inject environment variables into the docker containers when they are built.

Create a copy of .env-local.sample as .env in the docker directory but don't add it to version control. Add the postgresql user password as the value for both variables.

Then in the docker-compose file (probably but not necessarily docker-compose.yml), where you might previously have had the following:

services:
   servicename:
      ...
      environment:
         ENVVARIABLE: imapasswordchangeme
         OTHERENVVARIABLE: notasecret

You should now have:

services:
   servicename:
      ...
      environment:
         ENVVARIABLE: ${VARFROMENVFILE}
         OTHERENVVARIABLE: notasecret