DEV Community

Spacelift team for Spacelift

Posted on Edited on Originally published at spacelift.io

Docker Env Vars in Practice

Environment variables are the simplest way to configure containers without rebuilding images — but Docker gives you multiple ways to inject them, and it’s easy to end up with a setup that’s brittle (or leaks secrets into image layers, logs, or repos).

In the full guide, we cover:

  • The main ways to pass env vars into containers (-e/--env, --env-file, and Docker Compose)
  • The difference between image defaults (ENV) and runtime configuration
  • How to manage env vars cleanly across environments (dev/staging/prod)
  • Best practices for safety and maintainability (especially when values are sensitive)

➡️ Read the full article on our blog:

https://spacelift.io/blog/docker-run-environment-variables

Top comments (0)