Confusing ARG and ENV causes build issues. Know when to use each. ARG – Build-Time Only: FROM node:18 ARG NODE_ENV=production ARG API_URL=https://api.example.com RUN echo “Building for ${NODE_ENV}” RUN npm install –${NODE_ENV} # ARG values NOT available at runtime! Build with ARG: docker build –build-arg NODE_ENV=development -t myapp . ENV – Runtime Variables: FROM node:18 ENV […]
Tag: Environment Variables
Kubernetes: Use ConfigMaps to Store Configuration Separately from Pods
Hardcoding config in containers requires rebuilding images. ConfigMaps separate config from code. Create ConfigMap: kubectl create configmap app-config \ –from-literal=API_URL=https://api.example.com \ –from-literal=MAX_RETRIES=3 Use in Pod: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 envFrom: – configMapRef: name: app-config Change config without rebuilding image – just update ConfigMap! Update ConfigMap: […]
.NET Core Configuration Magic: How IOptions Pattern Solves Multi-Environment Headaches
Tired of connection strings breaking between dev/test/prod? IOptions pattern with validation ensures your app never starts with wrong config. The Configuration Nightmare: // The old way – scattered magic strings public class OrderService { private readonly string _connectionString; public OrderService(IConfiguration configuration) { _connectionString = configuration.GetConnectionString(“DefaultConnection”); // What if configuration key doesn’t exist? // What if […]


