✦ For everyone, free.

Practical knowledge for real and everyday life

Home

6.3.1.2 Environment App Profiles

A focused guide to Environment App Profiles, connecting core concepts with practical Docker and container operations.

Environment app profiles refers to using an environment variable to select among several predefined configuration profiles — development, staging, production — each bundling together a set of related settings appropriate for that specific context, rather than configuring every individual setting independently.

Selecting a Profile Through a Single Variable

A single environment variable can determine which broader configuration profile an application should use, with the application internally mapping that profile name to its full set of associated settings.

docker run -e APP_PROFILE=production myapp:1.0
import os
profile = os.environ.get("APP_PROFILE", "development")

profiles = {
    "development": {"debug": True, "log_level": "debug"},
    "staging": {"debug": False, "log_level": "info"},
    "production": {"debug": False, "log_level": "warn"},
}

config = profiles[profile]
Why Profiles Are Useful Beyond Individual Variables

Bundling related settings together under a single profile name reduces the risk of inconsistent configuration — accidentally enabling debug mode in production, for instance — that could arise from configuring many individual, unrelated variables separately for each environment.

docker run -e APP_PROFILE=production myapp:1.0

This single variable ensures every production-appropriate setting is consistently applied together, rather than requiring each one to be individually and correctly specified.

Allowing Individual Overrides on Top of a Profile

A chosen profile can still be supplemented with individual variable overrides for settings that genuinely need to differ from the profile's defaults in a specific deployment.

docker run -e APP_PROFILE=production -e LOG_LEVEL=debug myapp:1.0

This uses the production profile's settings generally, while specifically overriding just the log level for this particular deployment.

Why Environment App Profiles Matter

Using a profile-based approach to environment configuration reduces the risk of inconsistent or incomplete configuration across different deployment contexts, while still allowing the flexibility to override specific settings when genuinely needed.