✦ For everyone, free.

Practical knowledge for real and everyday life

Home

12.1.3.3 Dev Environment Variables

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

Dev environment variables configure an application's behavior specifically for local development — verbose logging, relaxed security checks, development-specific feature flags — distinct from the environment variables that would be set for a production deployment of the same application.

Typical Development-Specific Environment Variables

A development configuration commonly sets variables enabling more verbose output and easier local debugging.

services:
  api:
    environment:
      - LOG_LEVEL=debug
      - NODE_ENV=development
      - ENABLE_DEBUG_ENDPOINTS=true

These values are deliberately different from what a production deployment would use, reflecting development's different priorities around visibility and debugging convenience.

Why Some Variables Should Never Carry Their Dev Value Into Production

A variable like ENABLE_DEBUG_ENDPOINTS=true, reasonable for local development, could expose unintended functionality or information if accidentally left enabled in a production deployment.

services:
  api:
    environment:
      - ENABLE_DEBUG_ENDPOINTS=false

Ensuring production's corresponding configuration explicitly sets this to a safe value, rather than relying on assumption, guards against this specific category of accidental exposure.

Managing Development Variables Through a Dedicated Env File

For a larger set of development-specific variables, a dedicated environment file keeps them organized separately from the Compose file itself.

LOG_LEVEL=debug
NODE_ENV=development
ENABLE_DEBUG_ENDPOINTS=true
services:
  api:
    env_file:
      - .env.development
Clearly Distinguishing Dev Variables From Production Ones in Documentation

Documenting which variables are specifically development-oriented, and what their corresponding production values should be, helps avoid the kind of accidental carryover that could introduce a security or behavioral issue.

| Variable | Development | Production |
|----------|-------------|------------|
| LOG_LEVEL | debug | info |
| ENABLE_DEBUG_ENDPOINTS | true | false |
Why Dev Environment Variables Matter

Deliberately setting and clearly documenting development-specific environment variable values, with explicit attention to which ones must never carry their development value into production, supports both an effective local development experience and a properly secured production deployment.