Environment variables#
Divio applications allow you to maintain separate configuration for each of the cloud environments as well as the local environment.
Environment variables are a good place for storing instance-specific configuration, such as settings that you don’t wish to hard-code into your application.
Cloud environments#
In Divio cloud applications, environment variables can be managed via the command line or via the Control Panel.
New or changed environment variables are not available to environments until they are redeployed.
Via the command line#
The Divio CLI allows you to retrieve environment variables from the command line. For example, use the following command to retrieve custom environment variables from the Live environment:
divio app environment-variables list -e live
Output:
Environment: live (<environment uuid>)
+--------------------+------------------+----------------+
| name | value | is_sensitive |
+====================+==================+================+
| SIMPLE_VAR_NAME | SIMPLE VAR VALUE | False |
+--------------------+------------------+----------------+
| SENSITIVE_VAR_NAME | | True |
+--------------------+------------------+----------------+
For more information, see the full overview of How to manage environment variables or the Divio CLI command reference.
Via the Control Panel#
In the application, select Env Variables.

Local environment#
Your local application also uses environment variables, Docker Compose specifies a file where they can be found, e.g.:
env_file: .env-local
Lines in the file should not contain spaces or quotation marks (see Docker’s documentation).
Where and when environment variables are applied#
Environment variables should apply only to environments, and not to states or processes that are independent of a particular environment.
When an application is running, it runs in a particular environment, so you can expect environment variables to apply.
When a application is being built (i.e. in the deployment phase), it should not be subject to any particular environment conditions.
However you can set environment variables during the build phase.
Environment variables with Aldryn (legacy)#
Many of the applications packaged for Divio deployment recognise a number of environment variables for your convenience.
See Aldryn Django addons (legacy) for lists of settings that can be provided as variables in some Divio addons.
They do this in their Addon configuration with aldryn_config.py files. To see
precisely how they are handled, refer to the aldryn_config.py
file of key
addons (important: make sure you are looking at the correct version of the
addon, as different versions of the packages will assume different variables
and settings):
Our uWSGI application gateway in Aldryn Django applications also recognises environment variables that commence UWSGI_
.