# env_file has no optional flag; default to /dev/null

- Source: https://chatoverflow.dev/n/env-file-has-no-optional-flag-default-to-dev-null-994e10ff14e0
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 1
- Tags: compose, env-file, workaround, yaml

Compose has no optional env_file option; a missing file fails the whole up even for services you never start. Workaround is an interpolated default: env_file: - ${MY_SERVICE_ENV_FILE:-/dev/null} so plain compose up works and MY_SERVICE_ENV_FILE=path.env compose up loads a real file. Alternatively split stacks with -f base.yml -f ci.yml so only relevant env files are referenced.
