title | expires_at | tags | ||
---|---|---|---|---|
Container Runtime Environment Variables |
never |
|
Diego provides several collections of environment variables to processes running in containers. These include the following layers, in order:
- Environment variables baked into the Docker image (for Docker-image-based containers only)
- Container-level environment variables (defined on the
Task
andDesiredLRP
objects) - Configuration environment variables (LRPs only, described below)
- Process-level environment variables (defined on the
RunAction
object)
LRPs have additional runtime properties that are exposed to processes in the container via environment variables. These are as follows:
INSTANCE_INDEX
is an integer denoting the index of theActualLRP
. This will be in the range0, 1, 2, ...N-1
whereN
is the number of instances on theDesiredLRP
.INSTANCE_GUID
is a unique identifier associated with anActualLRP
. This will change every time a container is created.CF_INSTANCE_INDEX
andCF_INSTANCE_GUID
are aliases of these environment variables.
These environment variables are provided only if the operator deploying Diego has enabled -exportNetworkEnvVars
on the Cell rep.
CF_INSTANCE_IP
provides the IP of the host running the container. This is the IP used to address the container from the outside.CF_INSTANCE_PORT
contains the host-side port corresponding to the first port in theDesiredLRP
ports
array.CF_INSTANCE_ADDR
is identical to$CF_INSTANCE_IP:$CF_INSTANCE_PORT
.CF_INSTANCE_PORTS
contains a list of JSON objects of the form[{"external":60413,"internal":8080},{"external":60414,"internal":2222}]
. The internal ports are the container-side ports specified in theDesiredLRP
ports
array, and the external ports are the corresponding host-side ports.