Chapter 6: Docker Images and Containers
6.7 Environment variables at run time
Pass config when you start the container — do not bake production secrets into the image.
docker run -d --name badge-api \
-p 8080:8080 \
-e APP_ENV=lab \
-e APP_URL=http://0.0.0.0:8080 \
badge-api-hello:0.1
For files of variables, -env-file can work for labs — keep that file gitignored like .env.
| Bake into image | Pass at run / orchestrator |
|---|---|
| App code, dependency versions | Secrets, per-env URLs |
| Default CMD | Feature flags for a specific deploy |