Containerize your apps, orchestrate deployments, and go from zero to a running Kubernetes cluster on a cloud provider.
Containers solve the "works on my machine" problem by packaging your app with all its dependencies into a portable unit. Docker is the de facto standard for building and running containers.
A container is not a VM. It shares the host OS kernel, making it far lighter and faster to start — typically under 500ms.
Start with a base image, copy your app files, install dependencies, expose the port, and define the startup command. Use multi-stage builds to keep production images small.
# Stage 1: build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: production
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm ci --only=production
EXPOSE 3000
CMD ["node", "dist/index.js"]Kubernetes orchestrates containers across a cluster. Key objects: Pod (smallest deployable unit), Deployment (manages replicas), Service (exposes pods), and Ingress (HTTP routing).
Use <code class="bg-emerald-100 px-1 rounded text-xs font-mono">kind</code> or <code class="bg-emerald-100 px-1 rounded text-xs font-mono">k3s</code> to run a full Kubernetes cluster locally. Avoid cloud cluster costs during development.
Create a Deployment and Service YAML manifest. Apply it with kubectl apply -f deployment.yaml. Use kubectl get pods to verify your pods are running.
Never use the latest tag in production. Always pin to a specific image digest or version tag to ensure reproducible deployments.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-api
spec:
replicas: 3
selector:
matchLabels:
app: my-api
template:
metadata:
labels:
app: my-api
spec:
containers:
- name: my-api
image: my-api:latest
ports:
- containerPort: 3000You will need Docker Desktop and kubectl installed. A free-tier cloud account (GCP, AWS, or Azure) is required for the Kubernetes cluster section.
DevOps engineer and cloud architecture consultant.
Join 15,000+ Indian developers and creators receiving our curated newsletter every Sunday morning.
No spam. Only high-quality content. Unsubscribe anytime.