Hasina Razafintsalama

Hasina RAZAFINTSALAMA

← Back to Blog
DevOps

Docker + Kubernetes: Orchestrating Your Services Without Getting Lost

Containers are great. But orchestrating dozens of them without Kubernetes knowledge quickly becomes a nightmare. Here is a practical primer.

2026-06-05·8 min

Docker changed how we build and ship applications. Kubernetes changed how we run them at scale. Understanding both is now a core skill for any backend engineer working on distributed systems.

Docker: the foundation

A Docker container packages your application with its dependencies into a portable, reproducible unit. The key artifact is the Dockerfile,it defines how the image is built.

dockerfile
# Example Dockerfile for a Laravel app
FROM php:8.3-fpm-alpine

WORKDIR /var/www

RUN apk add --no-cache git curl
RUN docker-php-ext-install pdo pdo_mysql opcache

COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader

COPY . .
RUN php artisan config:cache && php artisan route:cache

EXPOSE 9000
CMD ["php-fpm"]

Kubernetes: orchestration at scale

Kubernetes (K8s) is the de facto standard for container orchestration. It handles service discovery, load balancing, auto-scaling, rolling deployments, and self-healing,automatically restarting failed containers.

Key Kubernetes concepts to master first: Pod (smallest deployable unit), Deployment (manages pod replicas), Service (network abstraction), Ingress (HTTP routing), and ConfigMap/Secret (configuration).

A minimal Kubernetes deployment

yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-service
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api-service
  template:
    metadata:
      labels:
        app: api-service
    spec:
      containers:
        - name: api
          image: my-registry/api-service:v1.2.0
          ports:
            - containerPort: 9000
          env:
            - name: DB_HOST
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: host

When does Kubernetes make sense?

  • You have more than 3–4 services running in production
  • You need automatic scaling based on traffic
  • You need zero-downtime deployments
  • Your team manages infrastructure as code

For smaller projects, Docker Compose with a simple VPS may be all you need. Kubernetes adds operational complexity,choose it when the benefits outweigh that cost.

Need help with this topic? Microservices Migration

Discover this service