Docker Compose Env Substitutor
Preview env var substitution in docker-compose.yml — see resolved values before deploying, nothing sent to any server
Paste your docker-compose.yml and .env file above to preview how your compose file looks after environment variable substitution. Supports ${VAR}, ${VAR:-default}, ${VAR:+alt}, ${VAR?error}, and $VAR patterns.
Docker Compose files use ${VARIABLE} syntax for environment variable substitution, but you can’t see the resolved values until runtime. If a variable is missing, Compose silently uses an empty string — or your default value might have a syntax error. This tool lets you paste your compose file and your .env values, then shows you the fully resolved output before you deploy.
Why Preview Substitution
Environment variable issues are among the hardest Docker Compose bugs to debug:
- Missing variables —
${DB_HOST}resolves to empty, and your app connects to nothing - Wrong defaults —
${PORT:-8080}vs${PORT-8080}behave differently when PORT is set but empty - Nested references —
${${ENV}_DB_HOST}doesn’t work in Compose (it’s not a shell) .envfile vs shell env — Compose reads.envautomatically, but shell-exported variables take precedence
This tool resolves all ${} references and highlights unresolved variables so you catch issues before deployment.
Substitution Syntax
Docker Compose supports these variable substitution patterns:
| Syntax | Behavior |
|---|---|
${VAR} | Value of VAR, empty if unset |
${VAR:-default} | Value of VAR, or default if unset or empty |
${VAR-default} | Value of VAR, or default if unset (empty is kept) |
${VAR:?error} | Value of VAR, or error if unset or empty |
${VAR?error} | Value of VAR, or error if unset |
How to Use
- Paste your
docker-compose.ymlin the left panel - Add your environment variables (KEY=VALUE format) in the right panel
- The tool resolves all
${}references and shows the final output - Unresolved variables are highlighted in the output
Example
Input compose file:
services:
app:
image: myapp:${APP_VERSION:-latest}
ports:
- "${HOST_PORT:-3000}:3000"
environment:
- DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@db:5432/${DB_NAME}
With variables:
APP_VERSION=2.1.0
HOST_PORT=8080
DB_USER=admin
DB_PASS=secret123
DB_NAME=production
The resolved output shows every ${} replaced with its actual value, making it easy to verify your configuration before deployment.
Frequently Asked Questions
Does it support the .env file format?
Yes. Paste your .env file contents (one KEY=VALUE per line) into the variables panel. Comments (lines starting with #) and empty lines are ignored.
What happens with undefined variables? Undefined variables without defaults resolve to empty strings, matching Docker Compose’s actual behavior. They’re highlighted in the output so you can spot them.
Does it handle variable substitution inside environment blocks?
Yes. Variables are resolved everywhere in the compose file — service names, image tags, port mappings, volume paths, environment values, and labels.
Is my configuration sent to a server? No. All substitution happens in your browser. Your environment variables and compose configuration never leave your device.