docs/current_docs/introduction/features/local-defaults.mdx
Dagger supports persisting default arguments in a local .env file. This avoids typing the same CLI arguments on every call — set them once, and they're applied automatically.
.env file in or above your module directory..env..env values.Place an .env file next to your dagger.json. Variables map directly to argument names without any module-name prefix:
ARGNAME=valueFUNCTIONNAME_ARGNAME=value# Constructor arg --registry
REGISTRY=ghcr.io/myorg
# Argument --tag on function "push"
PUSH_TAG=latest
Place an .env file in a parent directory (Dagger searches upward automatically). Variables must be prefixed with the module name:
MODULENAME_ARGNAME=valueMODULENAME_FUNCTIONNAME_ARGNAME=value# Constructor arg --registry on module "deploy"
DEPLOY_REGISTRY=ghcr.io/myorg
# Argument --tag on function "push" of module "deploy"
DEPLOY_PUSH_TAG=latest
:::note
All variable name matching is case-insensitive. TOKEN, token, and Token all match an argument named token.
:::
Consider a module called deploy with a constructor taking --registry and a function push taking --tag.
Without .env, you must pass every argument each time:
dagger call --registry=ghcr.io/myorg push --tag=latest
With an inner .env file (next to dagger.json):
REGISTRY=ghcr.io/myorg
PUSH_TAG=latest
# Arguments are filled in automatically
dagger call push
With an outer .env file (in a parent directory):
DEPLOY_REGISTRY=ghcr.io/myorg
DEPLOY_PUSH_TAG=latest
# Same result — module name prefix is stripped automatically
dagger call push
Values use the same format as CLI arguments: strings, integers, booleans, JSON arrays, local and remote paths for Directory/File types, secret provider URIs (env://, file://, op://, etc.), and more. See the Arguments reference for the full list.
When the same argument is defined in multiple places, the highest-priority source wins:
.env file defaults:::tip
.env to .gitignore if it contains secrets or personal preferences..env files let you skip the module name prefix for shorter variable names.${VAR} syntax), with fallback to host environment variables.
:::.env values