Variable Propagation Behavior
Yes, the local docker-compose output generated by the Railway CLI excludes variables marked as preview-only. These variables are designed specifically for the Railway cloud orchestration layer and are not propagated to local development environments to prevent configuration leakage and maintain a strict boundary between local development and remote preview stages.
Explanation of Environment Isolation
Railway distinguishes between global project variables and environment-specific variables. While the CLI can pull variables to your local machine, it prioritizes the active environment context. Because a local docker-compose run is not technically a "Preview Environment" hosted on Railway's infrastructure, the CLI does not inject variables scoped exclusively to the preview tier into the local compose file or the resulting container environment.
This behavior is consistent across modern CLI versions (2.x+), as the architectural goal is to ensure that local development mirrors the base production/development configuration, while preview-only variables handle ephemeral, branch-specific cloud resources (such as temporary database URLs or API keys for staging services).
Steps to Synchronize Local and Preview State
If you need to test a feature locally that depends on a preview-only variable, you must manually bridge the gap:
- Identify the missing variable: Check the Railway Dashboard under the Variables tab for your specific preview environment.
- Manual Injection: Add the required key-value pair to your local
.env file.
- Restart Containers: Run
docker-compose down && docker-compose up to ensure the new environment variable is picked up by the containers.
Verification Command
To verify which variables are currently available to your local CLI context versus what is on the server, use:
railway variables
Compare this output with the variables listed in the Railway Dashboard for the preview environment to identify the discrepancy.
Required Diagnostic Detail
To provide a more specific resolution, please clarify: Are you using a shared .env file managed by a third-party tool, or are you relying exclusively on the Railway CLI to generate the environment state?