smaple.tr
Cloud & DevOps

Docker Compose vs Kubernetes: When One Server Stops Being Enough

Mehmet Kurtipek
July 13, 2026
13 min read
Cloud & DevOps
Docker
Kubernetes
Containers

Docker Compose runs a multi-container application on one machine: you describe the services in a single YAML file and start them with one command. Kubernetes runs containers across a cluster of machines and keeps them in the state you declared, restarting what crashes, moving work off a failed node, rolling out new versions gradually and adding replicas under load. If one server can carry your traffic and you can live with some downtime when that server fails, Compose is enough; if you can't, look at a managed container service before you take on a Kubernetes cluster.

Both run the same images, built from the same Dockerfile, so switching later is a deployment project that leaves most of your application code alone. What you are really deciding is how many machines you need and how much infrastructure your team is prepared to operate.

What each tool does

Docker builds an image from a Dockerfile and runs it as a container. Compose adds a file, compose.yaml, that lists everything an application needs (web app, background worker, database, cache) with its environment, ports and volumes. docker compose up starts all of it on one Docker host, on a private network where the services reach each other by name.

Kubernetes works a level above that. You give it a set of machines, called nodes, and declarations of what should run: three replicas of this image, each with this much memory, reachable under this name. The control plane keeps comparing what is running with what you declared and closes the gap on whichever nodes have room.

Two things confuse people here. Kubernetes doesn't need Docker Engine on its nodes: dockershim was removed in Kubernetes 1.24, clusters run containers through containerd or CRI-O, and images built with docker build run unchanged. And Docker has its own multi-host mode, Swarm, which deploys Compose-style files across several machines. It comes up again below.

Docker Compose

Kubernetes

Runs on

One Docker host

A cluster of nodes

A container crashes

Restarted by its restart policy

Restarted; a failing liveness probe also triggers a restart

The machine dies

Everything is down until the host is back

Pods are rescheduled onto healthy nodes

New version

Containers are stopped and recreated

Rolling update gated by readiness probes; old pods keep serving if new ones never become ready

More capacity

More replicas on the same host, by hand

Replicas spread across nodes, automatic with an autoscaler

Traffic from the internet

A published port behind a reverse proxy

A Service plus Gateway API or Ingress, through a controller you install or enable

What you operate

One server and Docker

Nodes, add-ons and version upgrades, plus the control plane unless it is managed

One detail in the second row catches people out. In plain Docker and Compose, a failing health check only marks a container unhealthy; the container keeps running and nothing restarts it. In Kubernetes, a failing liveness probe restarts the container and a failing readiness probe takes it out of the Service until it recovers.

The same app, written for both

A common shape for a small product is a web app, a background worker built from the same image, PostgreSQL, and Redis as the queue. In Compose, the whole stack fits on one screen of compose.yaml:

services:
  web:
    image: registry.example.com/shop/web:1.8.0
    ports:
      - "127.0.0.1:8000:8000"
    env_file: .env.production
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    restart: unless-stopped

  worker:
    image: registry.example.com/shop/web:1.8.0
    command: celery -A shop worker --loglevel=info
    env_file: .env.production
    depends_on:
      - db
      - redis
    restart: unless-stopped

  db:
    image: postgres:17
    environment:
      POSTGRES_USER: shop
      POSTGRES_DB: shop
      POSTGRES_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD is not set}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U shop -d shop"]
      interval: 5s
      timeout: 3s
      retries: 10
    restart: unless-stopped

  redis:
    image: redis:8
    restart: unless-stopped

volumes:
  pgdata:

docker compose up --wait starts everything and returns once the services are running and the database reports healthy.

Two lines are there for production. The port is bound to 127.0.0.1 because ports that Docker publishes skip the host's ufw rules, so without it the app can be reachable from outside even with the firewall on; a reverse proxy on the same machine, such as Caddy or Nginx, handles TLS and forwards to it. And ${DB_PASSWORD:?...} is filled in from your shell or from a .env file next to compose.yaml, not from .env.production. Without the :?, a missing value only produces a warning, the password ends up empty and the Postgres container refuses to initialise.

Here is only the web service in Kubernetes, with a Service and a Gateway API route to expose it:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: registry.example.com/shop/web:1.8.0
          ports:
            - containerPort: 8000
          envFrom:
            - secretRef:
                name: shop-env
          resources:
            requests:
              cpu: 250m
              memory: 256Mi
            limits:
              memory: 512Mi
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8000
            periodSeconds: 5
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8000
            initialDelaySeconds: 15
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8000
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: web
spec:
  parentRefs:
    - name: public
  hostnames:
    - shop.example.com
  rules:
    - backendRefs:
        - name: web
          port: 80

It is longer, and it still covers only one service. What matters more is everything the Compose file decided for you that you now decide yourself:

  • depends_on has no direct equivalent. There is no start order between Deployments (an init container can wait for a dependency, but most teams make the app retry its database connection instead), and the readiness probe keeps traffic away until the app can serve.
  • The Postgres volume becomes a PersistentVolumeClaim in a StatefulSet, or, more often, a managed database outside the cluster. Redis gets the same decision.
  • Someone has to create the shop-env Secret: by hand with kubectl, or through an operator such as External Secrets Operator that syncs it from your cloud's secret manager.
  • The HTTPRoute assumes a Gateway called public and a Gateway API implementation installed in the cluster. Someone installs it, upgrades it and keeps its certificates valid.
  • The cluster only pulls finished images from a registry. There is no equivalent of Compose's build: key, so CI has to build and push every image.

When Docker Compose is enough

Compose on a single, well-run server is a sound production setup for more products than its reputation suggests. Docker's own guidance on Compose in production treats one server as the simplest way to deploy and recommends a separate override file for production settings. Compose fits when:

  • One server handles your peak load with room to spare. Vertical scaling goes a long way; every major cloud provider rents machines with dozens of cores and hundreds of gigabytes of memory.
  • You can accept an outage while that server is replaced. With tested backups and the host defined as code (Terraform, or even a well-kept script), rebuilding it becomes a routine job.
  • A short interruption during each deploy is acceptable, or you deploy outside busy hours. Compose stops and recreates a service's containers when its image or configuration changes.
  • The workload is an internal tool, a B2B product used during office hours, an MVP, a staging environment, or batch jobs that can safely be re-run.

If you run Compose in production, do the boring parts properly. Keep production settings in an override file (docker compose -f compose.yaml -f compose.production.yaml up -d), pin image tags, give every service a restart policy, back up the volumes and test the restore, and configure log rotation. Docker's default json-file log driver doesn't rotate, so container logs grow until the disk is full. Set "log-driver": "local" (it rotates by default) or max-size and max-file in /etc/docker/daemon.json, then recreate the containers: existing ones keep the log settings they were created with.

Signs you have outgrown one server

  • An outage when the host fails is no longer acceptable: there is an SLA in a contract, users in several time zones, or payments going through the app.
  • The load no longer fits on one reasonably sized machine, or it is spiky enough that paying for the peak all month hurts.
  • Deploys have to be invisible to users, with health-gated rollouts and automatic rollback.
  • Several teams ship services independently and keep stepping on each other on a shared host.
  • You need something from the Kubernetes ecosystem: an operator that runs a database or message broker for you, a vendor that only ships a Helm chart, or a customer who wants your software installed in their own cluster.

Only the last item is a reason for Kubernetes specifically. The first four are reasons to run on more than one machine, and there are simpler ways to get there.

The middle option: a managed container service

AWS ECS on Fargate, Google Cloud Run and Azure Container Apps take a container image and a short service definition and run it on the provider's machines, with rolling deploys, health checks, load balancing and autoscaling. There are no nodes to patch and no cluster version to upgrade, and the bill follows the CPU and memory your containers request or use. In exchange you give up some flexibility: the service definitions are specific to that cloud, and Kubernetes add-ons don't apply.

Oplist, a hospital rostering platform we build for, is one example: it runs on AWS, on ECS Fargate, Lambda and CloudWatch.

Docker Swarm is the other middle option. It is still part of Docker Engine, and docker stack deploy takes a Compose file and spreads the services over several machines. Two catches: its ecosystem is small next to Kubernetes, and docker stack deploy reads the legacy version 3 Compose format, so features of the current Compose Specification aren't supported and build is ignored. If your team already runs Swarm happily, there is no reason to move. On a new project, a managed container service is less to run.

If you do need Kubernetes, GKE Autopilot, EKS Auto Mode and AKS Automatic hand most of the node management to the provider. Add-ons and the Kubernetes APIs your workloads depend on remain your responsibility.

What Kubernetes really costs

The control plane fee is the small part. EKS charges $0.10 per cluster per hour, about $73 a month, rising to $0.60 an hour (about $438 a month) once the cluster's Kubernetes version moves into extended support. GKE charges the same $0.10 an hour, but its free tier gives each billing account a $74.40 monthly credit, enough for one zonal or Autopilot cluster. AKS's Free tier has no management fee and no financially backed uptime SLA; Microsoft recommends it for development, testing and clusters under 10 nodes, and the Standard tier adds the SLA for an hourly fee. Nodes, load balancers and storage come on top in every case.

Time is the bigger cost. The Kubernetes project ships a new minor version about every four months. On EKS, each version gets 14 months of standard support and then 12 months of extended support, and when that runs out AWS upgrades the control plane itself, without notice. That upgrade covers only the control plane; managed node groups, self-managed nodes and add-ons stay on the old version until you update them. Every upgrade means checking for removed APIs, updating add-ons and rolling the nodes.

The add-ons move too. Ingress NGINX, one of the most common ways to get HTTP traffic into a cluster, has been retired: best-effort maintenance ended in March 2026, there are no further releases or security fixes, and the project tells users to move to Gateway API or another Ingress controller. Teams still running it have an unpatched component at the front door of their cluster until they migrate.

Before choosing Kubernetes, ask whether someone on the team will own the cluster, its upgrades and its add-ons, and answer the pager when it misbehaves. If nobody will, a managed container service or a single Compose host with good backups will cost you less, in money and in evenings.

Moving from Compose to Kubernetes

If you have decided to move, these steps cover most of the work, roughly in this order:

  1. Build images in CI and push them to a registry, tagged by version or commit. Our GitHub Actions CI/CD guide covers that part.
  2. Generate a first draft of the manifests with Kompose (kompose convert) or Docker's Compose Bridge, which outputs Kubernetes manifests and a Kustomize overlay. Treat the result as a draft: Kompose prints a warning and skips any key it can't translate.
  3. Replace start order with readiness probes and connection retries in the application.
  4. Move state out of the cluster where you can: managed PostgreSQL, managed Redis, object storage for uploads.
  5. Keep secrets out of env files and images; store them in Kubernetes Secrets synced from your cloud's secret manager.
  6. Route traffic with Gateway API from the first day.
  7. Set CPU and memory requests on every container. Pods with no requests or limits get the BestEffort quality-of-service class, and the kubelet evicts them first when a node runs short of memory.
  8. Keep the Compose file for local development.

Run both setups side by side for a while. Send a small share of traffic to the new one first, with weighted DNS or a load balancer rule, and switch fully once it has handled real load. This only works once both setups point at the same database, which is another reason to do step 4 early.

Frequently asked questions

Can Docker Compose scale a service?

On one machine, yes: docker compose up -d --scale worker=4 runs four copies of the worker. Compose won't spread them across machines, though, and a service that publishes a fixed host port, like web above, can't run a second copy at all; it fails with "port is already allocated". To run several copies of web on one host, drop the host port and put a proxy on the Compose network in front of them.

How many nodes does a production Kubernetes cluster need?

With a managed control plane, three worker nodes, one per availability zone, is a sensible minimum. Size them so that two can carry the full load: nodes are drained and replaced on every upgrade, not only when they fail. If you run the control plane yourself, add three control-plane nodes. etcd needs a majority of its members to keep working, so a two-member etcd survives no more failures than a one-member one.

Does Kubernetes on a single server (k3s, MicroK8s) make sense?

k3s and MicroK8s run a certified Kubernetes distribution on one machine with little overhead. You get the API, Helm charts and operators; you don't get availability, because the machine is still a single point of failure. It is worth it when you need that tooling or want the same manifests as a customer's cluster. Otherwise Compose is less to learn and less to maintain.

If you are weighing this for a product of your own, send us a short description of your setup and we will tell you which side of the line we think it falls on.

Related Articles

July 21, 2026

AWS Cloud Architecture: A Practical Blueprint and What It Costs

The AWS setup we would suggest for most web apps and SaaS products, layer by layer: accounts, network, compute, data and operations, with October 2026 prices for Frankfurt.

Read More: AWS Cloud Architecture: A Practical Blueprint and What It Costs
July 20, 2026

Cloud Migration Strategy: How to Pick the Right R for Each App

Choose one of the 7 Rs per application, map what each system talks to, move in waves, rehearse the rollback and budget for the costs most migration plans leave out.

Read More: Cloud Migration Strategy: How to Pick the Right R for Each App
July 18, 2026

AWS Cost Optimization: What to Fix First, and What It Saves

The order matters more than any single trick: clean up, rightsize and move to Graviton before you buy Savings Plans. Worked examples use AWS list prices from October 2026.

Read More: AWS Cost Optimization: What to Fix First, and What It Saves