Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 100/ 160
05. Docker Compose & Multi-Container Apps

Migrating from Docker Compose to Kubernetes (Kompose & Patterns)

Map Compose services to Kubernetes objects and use Kompose thoughtfully.

AdvancedKompose · Deployments3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Use the migration as a mapping exercise: preserve application contracts, then redesign lifecycle and storage for a scheduler.

Think of it like…

Kompose is a language translator; it preserves rough sentences, but legal and operational idioms still need a native Kubernetes writer.

Where you’ve seen it

In practice, kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ is the concrete move for this job: map Compose services to Kubernetes objects and use Kompose thoughtfully. The release is not accepted until compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent confirms the result.

Words you’ll hear

Kompose
The implementation control in kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ for map Compose services to Kubernetes objects and use Kompose thoughtfully.
Deployments
The result to observe with compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent, rather than infer from a successful command alone.
Migration
The production boundary exposed when applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.

Visual diagram

Loading interactive diagram

Theory & deep dive

Kompose control path

The concrete mechanism is kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/. The observable result is compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent; if those disagree, inspect the runtime evidence before changing unrelated settings.

Map Compose services to Kubernetes objects and use Kompose thoughtfully. Keep Kompose, Deployments and Migration in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Kompose setup

kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/

Key takeaway: Prove Deployments with compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent, not with command success alone.

Migration failure boundary

Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials. The narrow failure to design for is applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.

Accept this compromise explicitly: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better. The controlled check-compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.

Key takeaway: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.

Use the migration as a mapping exercise: preserve application contracts, then redesign lifecycle and storage for a scheduler.
Key numbers at this step
Intent
Kompose

When to use it & trade-offs

What it is

Kompose can translate Compose services into Kubernetes objects, but networking, scaling, health, secrets and persistence require platform-specific review. A Service exposes Pods, a Deployment owns desired replicas, ConfigMaps/Secrets inject config, and PersistentVolumeClaims request storage.

Why it matters: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.

When to reach for it

  • The fit is strongest for this job: map Compose services to Kubernetes objects and use Kompose thoughtfully. Pair it with compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent in the runbook.
  • Production Kompose changes should make Deployments observable through kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/, rather than trusting the runtime default.
  • Keep a rollback example for the case where applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.

When to avoid or be careful

  • Do not accept command success while the system can still fail by applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
  • Avoid erasing Migration protection merely to dodge this cost: “Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better”.
  • Do not replace the evidence path-compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent-with a screenshot or a mutable tag.

kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/: practical choices

Explicit Kompose
Best for: Map Compose services to Kubernetes objects and use Kompose thoughtfully, with a reviewed runbook.

Strengths: Kompose can translate Compose services into Kubernetes objects, but networking, scaling, health, secrets and persistence require platform-specific review. A Service exposes Pods, a Deployment owns desired replicas, ConfigMaps/Secrets inject config, and PersistentVolumeClaims request storage.

Watch out: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.

Ambient default
Best for: Short-lived Deployments experiments with low blast radius.

Strengths: It can begin with kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ and fewer surrounding controls.

Watch out: It silently accepts applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability, which makes the result hard to reproduce after promotion.

Managed Migration
Best for: Teams that centralize Migration policy across many workloads.

Strengths: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.

Watch out: The platform adds an ownership and debugging layer; retain compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent as the direct check.

Interview signals & numbers to know

When this topic comes up

  • kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/
  • compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent
  • Failure signature: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability
  • Trade-off: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.

Benchmarks & rules of thumb

4 core mappings -
service→workload+Service, volume→PVC, env→ConfigMap/Secret
1 scheduler -
replaces Compose’s one-host controller
0 direct depends_on contract -
in ordinary Deployment readiness

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ as proof and skipping compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent.
  • Applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability
  • Optimizing Kompose without accepting that automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.

Likely interviewer follow-ups

  • Why does kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ address Kompose here rather than through application code?
  • How would you distinguish healthy Deployments from the failure “applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability” using compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent?
  • When would this trade-off-“Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better”-justify a different Migration design?
Interview tip: Give one concrete operation-kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/-and one proof-compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent. Then name the boundary: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Migrating from Docker Compose to Kubernetes (Kompose & Patterns) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Testing Multi-Container Stacks in CI with Docker Compose
Next topic
Container Threat Model & Attack Surface Overview