Environment variables are user defined key-value pairs that can configure the behaviour of applications at runtime. Common ways they are used are for storing things like API keys, username/passwords, JVM runtime options, locale, etc.
You can use the commands env or printenv to check the environment variables set and if you are not happy with the variables set at the Container creation time you can update these variables at any time.
The steps to add new key-value pairs follows:
Environment variables are stored on your server as an env file for docker. All variables in the file are stored wrapped in single quotes to preserve their literal values. This can have potentially unexpected effects so it is worth exploring a few examples:
| Control Panel Value | Value in Container | Notes |
|---|---|---|
hello there |
hello there |
|
general\tkenobi\n |
general\tkenobi\n |
Backslashes are treated literally, not as escape characters |
$SOME_VAR |
$SOME_VAR |
Variable interpolation is disabled |
'single quoted' |
'single quoted' |
Single quotes are preserved literally |
To remove environment variables, do the following:
The container will be restarted for the environment variable changes to take effect.
This is actually much easier than it sounds as Silverstripe already supports this out of the box. Simply add the environment variables Silverstripe is looking for through the SiteHost Control Panel, and the framework will take care of the rest.
This should be sufficient to get a simple Silverstripe site up and running:

The environment variables loaded here will have priority over any included in the .env file, so there should no conflicts when setting this up. If you have all the variables Silverstripe needs here you can even do away with the .env file altogether!