Skip to content

Chapter 10 of 10

Advanced Topics: Swarm and Kubernetes Integration

Place Docker workflows in multi-host orchestration with Swarm services and Kubernetes workloads.

46 minutes 10 quick checksBy Subha Prasad
Lesson 10 of 10Course navigation

Lesson content

Read, practise, then check your understanding

Advanced Topics: Swarm and Kubernetes Integration

A single Docker daemon manages one host. Orchestrators add desired state, scheduling, service discovery, rolling updates, health management, secrets, and multi-host networking. Docker Swarm is built into Docker Engine; Kubernetes is a broader orchestration platform that commonly consumes OCI-compatible images built with Docker.

Core ideas

  • A Swarm service declares an image, replicas, networks, update policy, and placement constraints.
  • A stack deploys a related group of Swarm services from a Compose-style specification.
  • Kubernetes uses resources such as Deployments, Services, ConfigMaps, Secrets, Jobs, and StatefulSets.
  • Kubernetes nodes use a CRI-compatible runtime such as containerd; Docker-built OCI images remain portable.

How it works

Build once, publish to a registry, and promote the same image digest across environments. The orchestrator should own restart, rollout, placement, and configuration. Add readiness and liveness signals that reflect actual behavior, define resource requests and limits, and plan stateful storage independently.

Command or configuration example

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: registry.example.com/api@sha256:REPLACE_WITH_DIGEST
          ports: [{ containerPort: 8080 }]
          resources:
            requests: { cpu: 100m, memory: 128Mi }
            limits: { memory: 256Mi }

Run examples first in a disposable environment. Replace image names, versions, credentials, ports, paths, and resource values with reviewed settings appropriate to your system.

Production guidance

  • Do not treat Compose, Swarm, and Kubernetes files as interchangeable despite overlapping concepts.
  • Use declarative delivery, immutable image digests, rollout health, and a tested rollback strategy.
  • Secure the registry, orchestrator API, node runtime, workload identity, network paths, and secret distribution.

The chapter quiz follows this lesson and checks the concepts as well as the operational tradeoffs.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement correctly describes Swarm mode?
Which term matches this explanation: Docker Engine's built-in clustering and service orchestration capability.
Which statement correctly describes service?
Which term matches this explanation: A desired-state Swarm workload replicated across nodes.
Which statement correctly describes stack?
Which term matches this explanation: A group of Swarm services deployed from a Compose-style file.
Which statement correctly describes Kubernetes?
Which term matches this explanation: A container orchestration system managing declarative workloads across clusters.
Which statement correctly describes container runtime?
Which term matches this explanation: Software that pulls images and starts containers for an orchestrator.

0 of 10 checks passed

Your progress is saved on this device.