When you create a new container, you can specify one or more environment variables.
Environment variables are key/values pairs which are made available to all instances within the workload.
Environment variables are used to set configuration values that are defined at runtime or during deployment, but are not embedded within a container image.
For example, for an application that accesses a third-party API, credentials may be required to authenticate. For security reasons, credentials should not be stored within the image, but are available at runtime through environment variables. This practice allows for credentials to be rotated, as well as avoids leaked credentials from the image and restricts access.
Set environment variables
You can set environment variables when you first create a container.
In the StackPath Control Portal, you will see the following workload settings:
To create a container:
- In the StackPath Control Portal, in the left-side navigation menu, Edge Computer.
- Click Workloads.
- Click Create Workloads.
- Follow the on-screen instructions.
To learn more, see Getting Started With StackPath Edge Computing.
Access environment variables
To access an environment variable programmatically, pull the variables from the OS or process.
To list these variables, in a terminal, ssh into your container.
- You can list all variables in the current session using the standard command printenv.
- To list all system wide variables use the standard command set.
The following example displays pulling the two system variables: