Skip to content

Environment variables

Manage configuration and secrets at the project or service level. Values are encrypted at rest.

Where vars come from

At runtime, Dockfly merges variables from three layers, in this order:

  1. Dockfly-injected PORT, DATABASE_URL, REDIS_URL, region info, and so on. These are set automatically.
  2. Project-level — shared across every service in the project. Set these for values all your services need.
  3. Service-level — overrides for a single service. These win when there's a conflict.

Add a variable

Open the service, go to the Variables tab, and click Add variable. Enter the key and value, then save. The service will restart automatically with the new variable in its environment.

You can also paste an entire .env file at once — click Import .env and paste the contents.

After a variable is saved its value is never shown again in the dashboard. To update it, set a new value — the old one is overwritten. To delete it, use the trash icon next to the variable.

Secrets vs. config

Dockfly treats every variable as a secret. Values are encrypted at rest with AES-256, never appear in build logs or deploy output, and are not included in any data export.

Auto-injected variables

Some variables are injected automatically — you don't need to set them and you can't override them. The most useful ones:

bash
PORT                # Port your service should listen on
DOCKFLY_REGION      # e.g. "sg1" — the region this service is running in
DOCKFLY_SERVICE_ID  # the service's unique ID
DOCKFLY_GIT_SHA     # commit SHA of the running build

# Set automatically when a database is in the same project:
DATABASE_URL        # postgres://user:pass@host:5432/db
REDIS_URL           # redis://:pass@host:6379
Your app must read PORT from the environment and bind to it — do not hardcode a port number. Dockfly assigns the port dynamically and routes traffic to it.