Docker and Kubernetes have become the standard for deploying modern applications. Our DevOps team at Softechinfra uses these technologies extensively for production deployments.
Docker Fundamentals
💡 Dockerfile Best Practices
Use specific versions, multi-stage builds, and non-root users for secure, optimized containers.
Dockerfile Best Practices
# Use specific version
FROM node:18-alpine# Set working directory
WORKDIR /app
# Copy package files first (caching)
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy source code
COPY . .
# Build application
RUN npm run build
# Use non-root user
USER node
# Expose port
EXPOSE 3000
# Start application
CMD ["node", "dist/index.js"]
Multi-Stage Builds
# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build# Production stage
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]
Image Optimization
Kubernetes Essentials
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-app:1.0.0
ports:
- containerPort: 3000
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 5Service
apiVersion: v1
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 3000
type: ClusterIPIngress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
tls:
- hosts:
- app.example.com
secretName: app-tlsConfiguration Management
ConfigMaps
apiVersion: v1
kind: ConfigMap
metadata:
name: my-app-config
data:
DATABASE_HOST: "postgres.default.svc"
LOG_LEVEL: "info"Secrets
apiVersion: v1
kind: Secret
metadata:
name: my-app-secrets
type: Opaque
data:
DATABASE_PASSWORD: base64encodedvalueUsing in Deployments
containers:
name: my-app
envFrom:
- configMapRef:
name: my-app-config
- secretRef:
name: my-app-secretsDeployment Strategies
Rolling Update
Default strategy, gradually replaces pods.
Blue-Green
Deploy new version alongside old, switch traffic.
Canary
Route percentage of traffic to new version.
# Using Nginx Ingress canary
metadata:
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "20"Monitoring
Health Checks
Liveness Probe: Is the application running? Readiness Probe: Is it ready to receive traffic?
Metrics
Logging
Best Practices
Security
Resource Management
Reliability
Conclusion
"Docker and Kubernetes provide powerful primitives for deploying applications. Start with fundamentals and build expertise over time."— Rishikesh Baidya, Lead Developer
Container orchestration is essential for modern deployments. We've deployed containerized applications for projects like TalkDrill using Kubernetes with our development expertise. Check our Kubernetes cost optimization guide for more tips.
Need Help with Container Deployments?
Our DevOps team designs and implements container strategies with Docker and Kubernetes for scalable, reliable production deployments.
Get DevOps Consultation →