✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Environment Feature Flags

Environment Feature Flags enable dynamic configuration management in Docker by allowing environment-specific settings to be toggled and managed efficiently

Environment feature flags use environment variables to toggle specific application behaviors on or off at run time, allowing a single image to support different feature configurations across different deployments without requiring separate builds for each variation.

Toggling a Feature Through an Environment Variable

A boolean-like environment variable determines whether a specific feature is active in a given running container.

docker run -e ENABLE_NEW_CHECKOUT=true myapp:1.0
import os
enable_new_checkout = os.environ.get("ENABLE_NEW_CHECKOUT", "false").lower() == "true"

if enable_new_checkout:
    # use new checkout flow
    pass
else:
    # use existing checkout flow
    pass

Why This Differs From a Dedicated Feature Flag Service

A dedicated feature flag service typically allows toggling features dynamically, without restarting the application, and can target specific users or percentages of traffic; environment-variable-based flags are simpler, fixed at container startup, and best suited for coarser, deployment-level toggles rather than fine-grained, dynamic targeting.

docker run -e ENABLE_NEW_CHECKOUT=true myapp:1.0

This flag's value is fixed for this container's entire running lifetime — changing it requires restarting the container with a different value, unlike a dynamic feature flag service that could change behavior in a running process without any restart at all.

Using Feature Flags for Gradual Rollouts Across Deployments

Different deployments — staging versus production, or different production regions — can be configured with different feature flag values, supporting a gradual rollout strategy at the deployment level.

docker run -e ENABLE_NEW_CHECKOUT=true myapp:1.0  # staging
docker run -e ENABLE_NEW_CHECKOUT=false myapp:1.0  # production

Why Environment Feature Flags Matter

Simple, environment-variable-based feature flags provide a lightweight way to control which features are active in a given deployment, well-suited to coarser, deployment-level toggles, without requiring the added complexity of a dedicated feature flag service for every situation.