Skip to content

Propagating Environment Variables in Docker

When running the Talisman Platform on Docker, environment-specific configurations can be managed using various approaches:

  • Environment Variables defined in environment specific docker-compose.yaml
  • Environment Variables propagated from host
  • Integration with Vault

This guide focuses on propagating Environment Variables from the host to an integration microservice.

Steps

1. Create Environment Variable on the Host

Define the required environment variable on the host system:

export ENV_NAME=value

2. Configure the Talisman Container

Propagate the host environment variable to the Talisman container using Docker Compose. Add the variable via the environment or env_file attribute in the Talisman container configuration:

talisman:
  environment:
    - ENV_NAME=${ENV_NAME}
# Alternatively, use an env_file:
  env_file:
    - .env

3. Set Environment Variables in Project Container

Set the configuration to include the environment variable in the project docker-compose.yaml:

services:
  my-project-id:
    container_name: my-project-id
    #...
    environment:
      ENV_NAME: ${ENV_NAME}

4. Use the Variable in the project

In your project routes, reference the environment variable using the {{env:ENV_NAME}} placeholder:

- log:
    message: "{{env:ENV_NAME}}"