The container runtime automatically sets the following variables:
CLOUDFLARE_APPLICATION_ID- the ID of the Containers applicationCLOUDFLARE_COUNTRY_A2- the ISO 3166-1 Alpha 2 code ↗︎ of a country the container is placed inCLOUDFLARE_LOCATION- a name of a location the container is placed inCLOUDFLARE_REGION- a region nameCLOUDFLARE_DURABLE_OBJECT_ID- the ID of the Durable Object instance that the container is bound to. You can use this to identify particular container instances on the dashboard.
Pass environment variables in the env option when you start a container instance with ctx.container.start():
const container = this.ctx.container;
container.start({
image: container.images.base,
enableInternet: false,
env: {
MY_CUSTOM_VAR: "value",
ANOTHER_VAR: "another_value",
},
});Processes that you start with exec() do not receive these variables, except PATH. Pass them in the env option of exec() instead.
More details about defining environment variables and secrets can be found in this example.