📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Docker Environment Variables

Environment Variables

4 min read
Pass configuration to containers via -e flags, --env-file, and Compose environment blocks.

Environment Variables

docker run -e NODE_ENV=production myapp
docker run --env-file .env myapp

# docker-compose.yml
services:
  web:
    environment:
      NODE_ENV: production
      PORT: 3000
    env_file:
      - .env

# Dockerfile
ARG BUILD_VERSION     # build-time only
ENV APP_PORT=3000     # runtime, visible in container