Environment variables
Application environment variables pass configuration to the image build, the running container, or both.
Open the application, then select Environment Variables.
Production and preview variables appear in separate labelled sections. Use the preview section for values that should differ, such as a preview database or callback URL.
Add variables
Use Normal view to configure one variable at a time. Select Add, enter Name and Value, choose its scope and value settings, then select Add variable. Select a variable name or its edit icon to change it, then select Update variable.
Use Developer view to paste or edit multiple values in .env format:
NODE_ENV=production
LOG_LEVEL=info
API_URL=https://api.example.comLines beginning with # are ignored. Saving Developer view creates, updates, and removes entries to match its contents.
Locked secrets and multiline values cannot be edited in Developer view. Change those entries in Normal view.
Build and runtime scope
Build time and Runtime are independent dropdowns. New variables default to Available during build and Available in the container.
| Setting | Image build | Running container |
|---|---|---|
| Build and runtime | Available | Available |
| Build only | Available | Not available |
| Runtime only | Not available | Available |
Set Build time to Not available during build for a secret that the application only reads after the container starts.
Traditional Docker build arguments can appear in image metadata. Set Build secrets to Docker BuildKit secrets for sensitive build-time values when the build server supports Docker BuildKit. If BuildKit is unavailable, Coolify falls back to build arguments.
Example: private npm registry
Authenticate to a private npm registry during the build with a build variable instead of committing a token to the repository.
-
Add an
.npmrcfile to your project root://registry.npmjs.org/:_authToken=${NPM_TOKEN} -
Add
NPM_TOKENwith Build time set to Available during build (the token is only needed duringnpm install), and set its value to your registry token. -
Deploy the application. The build reads
NPM_TOKENand authenticates to the registry.
Multiline and literal values
Set Value type to Multiline when a value contains line breaks, such as a private key, certificate, or configuration file.
Set Interpolation to Literal (keep $ characters as-is) when characters such as $ must remain unchanged. Without it, Coolify can expand references contained in the value. Multiline values are already treated literally.
Shared variables
Reference a team, project, environment, or server variable instead of copying the same value into every resource:
{{environment.DATABASE_URL}}Follow Shared variables to create a value at the correct scope and assign it to an application variable.
External secret managers
Link Doppler, Infisical, or HashiCorp Vault and reference a remote value with {{vault.KEY}}. Follow Use a secret manager.
Predefined application variables
Coolify makes deployment information available through predefined values.
| Variable | Value |
|---|---|
COOLIFY_FQDN | Application domain names. |
COOLIFY_URL | Application URLs. |
COOLIFY_BRANCH | Selected Git branch. |
COOLIFY_RESOURCE_UUID | Coolify resource identifier. |
COOLIFY_CONTAINER_NAME | Generated container name. |
SOURCE_COMMIT | Deployed Git commit. |
PORT | First exposed port when PORT is not already set. |
HOST | 0.0.0.0 when HOST is not already set. |
Coolify excludes SOURCE_COMMIT from Docker builds by default to preserve cache reuse. Set Advanced > Build > Source commit availability to Available during build when the build needs it.
Assign a predefined value to your own key when the application expects another name:
APP_REVISION=$SOURCE_COMMITDocker Compose variables
Coolify detects variable references in a Compose definition and displays them as application variables:
services:
api:
environment:
DATABASE_URL: ${DATABASE_URL}
LOG_LEVEL: ${LOG_LEVEL:-info}
API_KEY: ${API_KEY:?}${API_KEY:?} marks the variable as required. Coolify blocks deployment while its value is empty.
For generated stack values such as URLs, users, passwords, and random strings, read Docker Compose.
Apply changes
Save the variables, then redeploy or restart the application so Coolify recreates the runtime environment.
Use a new deployment when build-time values changed. Use Restart when only runtime values changed. Source-based paths reuse an existing image when eligible; Docker Image pulls the saved image reference again.
Names and copying values
New environment variable names must match [A-Za-z_][A-Za-z0-9_.]*: begin with a letter or underscore, then use letters, numbers, underscores, or dots. Existing invalid runtime-only names, such as my-var, deploy with a warning and suggested name. Invalid build-time names stop the image build.
Use the copy button to copy a resolved value. Shared-variable and $SERVICE_* references resolve to their actual values. Locked variables have no copy button, and references to locked shared variables remain references rather than exposing the secret.
