This page documents all environment variables and configuration options used across the Docker services.
Infrastructure Services
PostgreSQL Databases
Both catalogdb and basketdb use PostgreSQL with identical configuration patterns.
Catalog Database
catalogdb:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=CatalogDb
ports:
- "5432:5432"
volumes:
- postgres_catalog:/var/lib/postgresql/data/
Basket Database
basketdb:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=BasketDb
ports:
- "5433:5432" # External port 5433 to avoid conflict
volumes:
- postgres_basket:/var/lib/postgresql/data/
Environment Variables:
| Variable | Value | Description |
|---|
POSTGRES_USER | postgres | Default PostgreSQL superuser |
POSTGRES_PASSWORD | postgres | Superuser password (change for production) |
POSTGRES_DB | CatalogDb/BasketDb | Initial database name |
Default credentials are used for development. Always use strong passwords and secure credential management in production.
SQL Server (Order Database)
orderdb:
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=SwN12345678
ports:
- "1433:1433"
Environment Variables:
| Variable | Value | Description |
|---|
ACCEPT_EULA | Y | Accept SQL Server End-User License Agreement |
SA_PASSWORD | SwN12345678 | System administrator password (must meet complexity requirements) |
SQL Server passwords must be at least 8 characters and contain uppercase, lowercase, numbers, and special characters.
Redis Cache
distributedcache:
container_name: distributedcache
restart: always
ports:
- "6379:6379"
Redis runs with default configuration. No authentication is configured for development.
RabbitMQ Message Broker
messagebroker:
container_name: messagebroker
hostname: ecommerce-mq
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
ports:
- "5672:5672" # AMQP protocol
- "15672:15672" # Management UI
Environment Variables:
| Variable | Value | Description |
|---|
RABBITMQ_DEFAULT_USER | guest | Default RabbitMQ user |
RABBITMQ_DEFAULT_PASS | guest | Default password |
Access Management UI: http://localhost:15672 (guest/guest)
Application Services
Common ASP.NET Core Settings
All .NET services share these common environment variables:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
| Variable | Value | Description |
|---|
ASPNETCORE_ENVIRONMENT | Development | Enables detailed errors, developer exception page |
ASPNETCORE_HTTP_PORTS | 8080 | Internal HTTP port |
ASPNETCORE_HTTPS_PORTS | 8081 | Internal HTTPS port |
Catalog API
catalog.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ConnectionStrings__Database=Server=catalogdb;Port=5432;Database=CatalogDb;User Id=postgres;Password=postgres;Include Error Detail=true
ports:
- "6000:8080"
- "6060:8081"
Connection String Format:
- Server:
catalogdb (container name)
- Port:
5432 (PostgreSQL default)
- Database:
CatalogDb
- User Id:
postgres
- Password:
postgres
- Include Error Detail:
true (development only)
Basket API
basket.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ConnectionStrings__Database=Server=basketdb;Port=5432;Database=BasketDb;User Id=postgres;Password=postgres;Include Error Detail=true
- ConnectionStrings__Redis=distributedcache:6379
- GrpcSettings__DiscountUrl=https://discount.grpc:8081
- MessageBroker__Host=amqp://ecommerce-mq:5672
- MessageBroker__UserName=guest
- MessageBroker__Password=guest
ports:
- "6001:8080"
- "6061:8081"
Additional Configuration:
| Variable | Value | Description |
|---|
ConnectionStrings__Redis | distributedcache:6379 | Redis connection for caching |
GrpcSettings__DiscountUrl | https://discount.grpc:8081 | gRPC endpoint for discount service |
MessageBroker__Host | amqp://ecommerce-mq:5672 | RabbitMQ AMQP connection |
MessageBroker__UserName | guest | RabbitMQ username |
MessageBroker__Password | guest | RabbitMQ password |
Discount gRPC Service
discount.grpc:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ConnectionStrings__Database=Data Source=discountdb
ports:
- "6002:8080"
- "6062:8081"
Connection String:
- Uses SQLite with file-based database
discountdb
- Database file stored in container filesystem
Ordering API
ordering.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ConnectionStrings__Database=Server=orderdb;Database=OrderDb;User Id=sa;Password=SwN12345678;Encrypt=False;TrustServerCertificate=True
- MessageBroker__Host=amqp://ecommerce-mq:5672
- MessageBroker__UserName=guest
- MessageBroker__Password=guest
- FeatureManagement__OrderFullfilment=false
ports:
- "6003:8080"
- "6063:8081"
SQL Server Connection String:
- Server:
orderdb (container name)
- Database:
OrderDb
- User Id:
sa (system administrator)
- Password:
SwN12345678
- Encrypt:
False (development only)
- TrustServerCertificate:
True (development only)
Feature Flags:
| Variable | Value | Description |
|---|
FeatureManagement__OrderFullfilment | false | Toggles order fulfillment feature |
YARP API Gateway
yarpapigateway:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
ports:
- "6004:8080"
- "6064:8081"
Gateway routing configuration is stored in appsettings.json within the container.
shopping.web:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ApiSettings__GatewayAddress=http://yarpapigateway:8080
ports:
- "6005:8080"
- "6065:8081"
API Configuration:
| Variable | Value | Description |
|---|
ApiSettings__GatewayAddress | http://yarpapigateway:8080 | Internal gateway URL for API calls |
Port Mappings
All port mappings follow the pattern HOST:CONTAINER:
| Service | HTTP (Host:Container) | HTTPS (Host:Container) | Purpose |
|---|
| catalog.api | 6000:8080 | 6060:8081 | Catalog service |
| basket.api | 6001:8080 | 6061:8081 | Basket service |
| discount.grpc | 6002:8080 | 6062:8081 | Discount service |
| ordering.api | 6003:8080 | 6063:8081 | Ordering service |
| yarpapigateway | 6004:8080 | 6064:8081 | API Gateway |
| shopping.web | 6005:8080 | 6065:8081 | Web UI |
| catalogdb | 5432:5432 | - | PostgreSQL |
| basketdb | 5433:5432 | - | PostgreSQL |
| orderdb | 1433:1433 | - | SQL Server |
| distributedcache | 6379:6379 | - | Redis |
| messagebroker | 5672:5672 | - | RabbitMQ AMQP |
| messagebroker | 15672:15672 | - | RabbitMQ Management |
Volume Mounts
Database Persistence
volumes:
- postgres_catalog:/var/lib/postgresql/data/
- postgres_basket:/var/lib/postgresql/data/
Named volumes persist database data between container restarts.
Development Secrets and Certificates
All .NET services mount user secrets and HTTPS certificates:
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro
- User secrets: Development-time secret storage
- HTTPS certificates: Development SSL/TLS certificates
:ro flag: Read-only mount
The ${APPDATA} environment variable resolves to the Windows user’s AppData folder. For Linux/macOS, adjust these paths to ~/.microsoft/usersecrets and ~/.aspnet/https.
Configuration Hierarchy
ASP.NET Core configuration is loaded in this order (later sources override earlier ones):
appsettings.json (in container)
appsettings.{Environment}.json (e.g., appsettings.Development.json)
- User Secrets (development only)
- Environment variables (from docker-compose)
- Command-line arguments
Docker Compose environment variables use double underscore __ to represent configuration hierarchy:
ConnectionStrings__Database → ConnectionStrings:Database
MessageBroker__Host → MessageBroker:Host
FeatureManagement__OrderFullfilment → FeatureManagement:OrderFullfilment
Security Considerations
The current configuration is optimized for development and should not be used in production without modifications.
Production Checklist
Docker Secrets Example
secrets:
db_password:
file: ./secrets/db_password.txt
services:
catalogdb:
secrets:
- db_password
environment:
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
Customizing Configuration
Override for Local Development
Create docker-compose.local.yml:
version: '3.4'
services:
catalog.api:
environment:
- ConnectionStrings__Database=Server=localhost;Port=5432;Database=CatalogDb;User Id=myuser;Password=mypass
Run with:
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.local.yml up
Environment-Specific Files
# Development
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
# Staging
docker-compose -f docker-compose.yml -f docker-compose.staging.yml up
# Production
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up