migration6 min read

Migrate from Docker Swarm to Kubernetes: Step-by-Step Guide

SFEIR Institute

Key Takeaways

  • 96% of organizations use or evaluate Kubernetes (The Decipherist)
  • Migration in 3-6 months: inventory, manifest translation, testing, progressive switch
  • Team training is critical for successful migration

A structured Docker Swarm to Kubernetes migration guarantees a transition without service interruption. With 96% of organizations using or evaluating Kubernetes according to The Decipherist, this migration has become essential for teams still on Docker Swarm. This guide details the technical phases to migrate from Docker Swarm to Kubernetes with confidence.

TL;DR: Plan 3-6 months for a complete migration. Start with service inventory, translate docker-compose files to Kubernetes manifests, test in parallel, then switch progressively. Team training is critical for success.

CKA-certified Kubernetes system administrators master these migrations thanks to the LFS458 Kubernetes Administration training.

Why is Docker Swarm to Kubernetes migration necessary?

Docker Swarm is still used by about 24% of organizations according to The Decipherist. However, Kubernetes dominates with 82% adoption in production according to the CNCF Annual Survey 2025.

Key takeaway: Evaluate business reasons before migrating. Kubernetes brings scalability and ecosystem, but Docker Swarm suffices for simple deployments.

Capability comparison

FeatureDocker SwarmKubernetes
ScalabilityHundreds of containersThousands of containers
Configurationdocker-compose.ymlMultiple YAML manifests
EcosystemLimitedVery rich (CNCF)
Learning~1 week1-3 months
Initial setup1 commandMulti-step

According to Portainer: Docker Swarm is configured in one command (docker swarm init) while Kubernetes requires a multi-step installation. This initial simplicity doesn't compensate for limitations at scale.

What are the Docker Swarm to Kubernetes migration preparatory steps?

Preparation represents 50% of success. Invest in inventory and documentation before any technical action.

Phase 1: Audit existing infrastructure

Document your entire Docker Swarm stack:

# Swarm services inventory
docker service ls --format "{{.Name}}\t{{.Replicas}}\t{{.Image}}"

# Export configurations
docker service inspect --pretty <service-name>

# Network analysis
docker network ls --filter driver=overlay

Create a structured inventory file:

ServiceReplicasImagePortsVolumesSecrets
api3api:v2.18080logsdb-creds
worker5worker:v2.1-dataapi-key
nginx2nginx:1.2580,443certstls-cert

See our kubectl vs Docker CLI cheatsheet for command equivalences.

Phase 2: Dependency analysis

Identify inter-service dependencies:

  • Synchronous communications (HTTP/gRPC)
  • Message queues (RabbitMQ, Redis)
  • Shared databases
  • Persistent volumes
Key takeaway: Map network flows before migration. A poorly sequenced service causes cascading failures.

How to translate docker-compose to Kubernetes manifests?

Converting docker-compose to Kubernetes follows established patterns. Kubernetes system administrator training covers these fundamentals.

Concept mapping

Docker SwarmKubernetesNotes
serviceDeployment + ServiceCompute/network separation
replicasspec.replicasIdentical
networksNetworkPolicyMore granular
volumesPersistentVolumeClaimStorage abstraction
secretsSecretBase64 encoding
configsConfigMapNot encrypted

Conversion example

Original Docker Compose:

version: '3.8'
services:
api:
image: api:v2.1
deploy:
replicas: 3
resources:
limits:
cpus: '0.5'
memory: 512M
ports:
- "8080:8080"
environment:
- DB_HOST=postgres
secrets:
- db-password

Equivalent Kubernetes manifests:

# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: api:v2.1
resources:
limits:
cpu: "500m"
memory: "512Mi"
ports:
- containerPort: 8080
env:
- name: DB_HOST
value: postgres
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-password
key: password
---
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- port: 8080
targetPort: 8080
type: ClusterIP

What are the Docker Swarm to Kubernetes migration steps for persistent data?

Persistent volumes require particular attention. Data loss represents the major risk of any container orchestrator migration.

Volume migration strategy

Plan according to data type:

Data typeStrategyDowntime
CacheRegenerationNone
SessionsDrain then migrateShort
DatabaseReplication then switchMinimal
Static filesCopy then syncNone
# Volume synchronization with rsync
kubectl run rsync-pod --image=alpine \
--overrides='{"spec":{"containers":[{"name":"rsync","image":"alpine","command":["sleep","infinity"],"volumeMounts":[{"name":"data","mountPath":"/data"}]}],"volumes":[{"name":"data","persistentVolumeClaim":{"claimName":"data-pvc"}}]}}'

kubectl exec rsync-pod -- rsync -avz /source/ /data/
Key takeaway: Test restoration before switching. An unverified backup is worthless.

See our guide on Kubernetes managed vs self-hosted to choose your target infrastructure.

How to migrate services with zero downtime?

Progressive migration minimizes risks. According to PhoenixNAP, Kubernetes scales to thousands of containers, allowing temporary cohabitation.

Blue-Green pattern

Deploy on Kubernetes in parallel with Swarm:

  1. Kubernetes infrastructure ready
  2. Services deployed and tested
  3. Load balancer configured for both backends
  4. Progressive traffic switching
  5. Intensive monitoring
  6. Swarm decommissioning
# Ingress for progressive switching (NGINX)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-ingress
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "20"
spec:
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-k8s
port:
number: 8080

Rollback plan

Prepare a documented rollback plan:

  1. Rollback criteria (latency, errors, business metrics)
  2. Reverse switch procedure
  3. Automated scripts
  4. Team communication

See our EKS vs GKE vs AKS comparison to choose your target platform.

What skills to develop for successful migration?

Team training determines long-term success. 104,000 people have taken the CKA exam with 49% growth according to the CNCF Training Report.

According to TealHQ: "Don't let your knowledge remain theoretical - set up a real Kubernetes environment to solidify your skills."

Skill development path

RoleRecommended trainingDuration
Ops/AdminLFS458 (CKA)4 days
DeveloperLFD459 (CKAD)3 days
BeginnerKubernetes fundamentals1 day

CKA certification validates skills with a minimum score of 66% on a 2-hour practical exam according to the Linux Foundation. Certification remains valid for 2 years.

Key takeaway: Train before migrating. A competent team reduces migration time by 60%.

See our Kubernetes tutorials and practical guides to support learning.

What pitfalls to avoid during Docker Swarm to Kubernetes migration?

Common mistakes extend migration projects by several months. The Kubernetes comparisons and alternatives page gathers experience feedback.

Common anti-patterns

Anti-patternConsequenceSolution
Big bang migrationHigh risk, complex rollbackProgressive migration
Underestimating secretsCredential leakagePrior security audit
Ignoring testsProduction regressionsSystematic automated tests
Neglecting monitoringUndetected problemsDay-one observability
# Secret verification before migration
docker secret ls
docker config ls

# Permission audit
docker node ls --format "{{.Hostname}}: {{.ManagerStatus}}"
PhaseDurationActivities
Preparation4-6 weeksAudit, training, platform choice
POC2-4 weeksTest cluster, 1 service migration
Migration8-12 weeksServices in criticality batches
Stabilization4 weeksMonitoring, optimization
Decommissioning2 weeksSwarm shutdown, cleanup

See our Kubernetes vs Docker Swarm comparison to validate your decision.

Take action: secure your migration

Docker Swarm to Kubernetes migration requires planning and skills. Invest in preparation to avoid costly failures.

Chris Aniszczyk from CNCF states in State of Cloud Native 2026: "Kubernetes is no longer experimental but foundational. Soon, it will be essential to AI as well." Anticipating this transition positions your organization for the future.

SFEIR Institute supports your teams in this transformation:

Contact our experts to define your migration strategy and training path suited to your team.