Docker Compose — Compose to Kubernetes
Docker Compose is perfect for single-host multi-container applications. When you need multi-host orchestration, automatic scaling, rolling updates, and self-healing, Kubernetes is the natural next step.
When to Outgrow Compose
| Scenario | Compose | Kubernetes |
|---|---|---|
| Local development | ✅ Ideal | ❌ Overkill |
| Single-server deployment | ✅ Good | ⚠️ Possible but heavy |
| Multi-server deployment | ❌ Not supported | ✅ Designed for this |
| Auto-scaling | ❌ Manual --scale |
✅ Horizontal Pod Autoscaler |
| Zero-downtime deploys | ⚠️ Limited | ✅ Rolling updates, blue-green |
| Self-healing | ⚠️ Restart policies only | ✅ Full lifecycle management |
| Service mesh | ❌ Not available | ✅ Istio, Linkerd |
Concepts That Transfer
The good news: almost every Compose concept has a Kubernetes equivalent.
Compose Concept → Kubernetes Equivalent
─────────────────────────────────────────────────
compose.yml → Deployment + Service YAML
services: → Deployments / StatefulSets
ports: → Service (NodePort/LoadBalancer)
volumes: → PersistentVolumeClaim (PVC)
networks: → NetworkPolicy / Services
environment: → ConfigMap / Secret
depends_on: → Init Containers / readiness probes
deploy.replicas: → spec.replicas
healthcheck: → livenessProbe / readinessProbe
profiles: → Namespaces / Helm values
Kompose — Convert Compose to K8s
Kompose is an official tool that converts compose.yml files to Kubernetes manifests:
# Install kompose
curl -L https://github.com/kubernetes/kompose/releases/latest/download/kompose-darwin-arm64 -o kompose
chmod +x kompose
sudo mv kompose /usr/local/bin/
# Convert your compose file
kompose convert
Expected output:
INFO Kubernetes file "api-service.yaml" created
INFO Kubernetes file "api-deployment.yaml" created
INFO Kubernetes file "postgres-service.yaml" created
INFO Kubernetes file "postgres-deployment.yaml" created
INFO Kubernetes file "redis-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "pg-data-persistentvolumeclaim.yaml" created
Important: Kompose generates a starting point, not production-ready manifests. You will always need to review and adjust the output.
Compose + Kubernetes Together
Many teams use both:
- Development:
docker compose upfor fast local iteration - Staging/Production: Kubernetes for orchestration at scale
- CI/CD: Compose for integration tests, K8s for deployment
This is not an either/or decision — Compose and Kubernetes complement each other.
Getting Started with Kubernetes
If you are ready to learn Kubernetes:
- Install minikube or kind for local practice
- Learn Pods, Deployments, Services, and ConfigMaps first
- Convert one of your Compose projects using Kompose
- Iterate — refine the generated manifests
# Quick start with minikube
brew install minikube
minikube start
kubectl get nodes
Quick Reference
| Item | Detail |
|---|---|
| Conversion tool | Kompose (kompose convert) |
| Local K8s | minikube, kind, Docker Desktop K8s |
| Key K8s concepts | Pods, Deployments, Services, PVCs |
| Compose + K8s | Use both — dev (Compose) + prod (K8s) |