Secrets Management

LEVEL 0

The Problem

Your application needs secrets:

  • Database passwords
  • API keys
  • OAuth tokens
  • TLS certificates

Where do you put them?

Bad ideas:

# Hardcoded in Dockerfile
ENV DB_PASSWORD=supersecret123

Anyone with the image can see it:

docker image inspect myapp | grep DB_PASSWORD
# In docker-compose.yml committed to git
environment:
  API_KEY: sk_live_abc123xyz

Now it’s in version control history forever.

# In environment variable in shell
export SECRET_KEY=my-secret
docker run -e SECRET_KEY myapp

Shows up in docker inspect and process list.

Secrets need special handling.