Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Docker Secrets

Published on

Updated on

I try to keep secrets such as passwords and keys out in their own separate files so that I can .gitignore them and commit the rest of my configuration. With docker-compose we can do that with the env_file field. Here is an example with a postgres configuration:

  image: postgres:13.4
  container_name: database
  hostname: database
    - Volumes/database/docker.env
    - Volumes/database/var/lib/postgresql/data:/var/lib/postgresql/data

Then in Volumes/database/docker.env I can have a file with the secrets as key-value pairs:

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :