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 142/ 160
08. Container Orchestration & Ecosystem

Orchestration Concepts (Scheduling, Self-Healing, Desired State)

Learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes.

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

In plain words

Describe desired state and SLO constraints, not imperative one-time commands, when the system spans many nodes and churn.

Think of it like…

Orchestration is a thermostat: a target is declared, sensors report reality and a controller repeatedly adjusts the machinery, but it cannot fix a broken heater.

Where you’ve seen it

In practice, docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1 is the concrete move for this job: learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes. The release is not accepted until drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns confirms the result.

Words you’ll hear

Scheduling
The implementation control in docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1 for learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes.
Desired State
The result to observe with drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns, rather than infer from a successful command alone.
Self-Healing
The production boundary exposed when describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.

Visual diagram

Loading interactive diagram

Theory & deep dive

Scheduling control path

The concrete mechanism is docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1. The observable result is drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns; if those disagree, inspect the runtime evidence before changing unrelated settings.

Learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes. Keep Scheduling, Desired State and Self-Healing in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Scheduling setup

docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1

Key takeaway: Prove Desired State with drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns, not with command success alone.

Self-Healing failure boundary

A scheduler can only use declared requests/limits and health. Without readiness, a replacement is scheduled but traffic may reach it too soon; without resource request it can be placed on an exhausted node. The narrow failure to design for is describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.

Accept this compromise explicitly: Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior. The controlled check-drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.

Key takeaway: Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: A scheduler can only use declared requests/limits and health. Without readiness, a replacement is scheduled but traffic may reach it too soon; without resource request it can be placed on an exhausted node.

Describe desired state and SLO constraints, not imperative one-time commands, when the system spans many nodes and churn.
Key numbers at this step
Intent
Scheduling

When to use it & trade-offs

What it is

An orchestrator continuously compares desired state-replica count, placement and resources-with observed state, schedules workloads to eligible nodes and reconciles failures. Self-healing means controllers create/replace objects within policy, not that bugs or data inconsistencies disappear.

Why it matters: A scheduler can only use declared requests/limits and health. Without readiness, a replacement is scheduled but traffic may reach it too soon; without resource request it can be placed on an exhausted node.

When to reach for it

  • The fit is strongest for this job: learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes. Pair it with drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns in the runbook.
  • Production Scheduling changes should make Desired State observable through docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1, rather than trusting the runtime default.
  • Keep a rollback example for the case where describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.

When to avoid or be careful

  • Do not accept command success while the system can still fail by describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.
  • Avoid erasing Self-Healing protection merely to dodge this cost: “Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior”.
  • Do not replace the evidence path-drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns-with a screenshot or a mutable tag.

docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1: practical choices

Explicit Scheduling
Best for: Learn scheduling, desired state, and self-healing ideas shared by Swarm and Kubernetes, with a reviewed runbook.

Strengths: An orchestrator continuously compares desired state-replica count, placement and resources-with observed state, schedules workloads to eligible nodes and reconciles failures. Self-healing means controllers create/replace objects within policy, not that bugs or data inconsistencies disappear.

Watch out: Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior.

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

Strengths: It can begin with docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1 and fewer surrounding controls.

Watch out: It silently accepts describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests, which makes the result hard to reproduce after promotion.

Managed Self-Healing
Best for: Teams that centralize Self-Healing policy across many workloads.

Strengths: A scheduler can only use declared requests/limits and health. Without readiness, a replacement is scheduled but traffic may reach it too soon; without resource request it can be placed on an exhausted node.

Watch out: The platform adds an ownership and debugging layer; retain drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns as the direct check.

Interview signals & numbers to know

When this topic comes up

  • docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1
  • drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns
  • Failure signature: describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests
  • Trade-off: Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior.

Benchmarks & rules of thumb

3 control-loop parts -
desired, observed and reconciler
3 replicas -
example desired state
1 placement constraint -
zone= a in the example

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1 as proof and skipping drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns.
  • Describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests
  • Optimizing Scheduling without accepting that declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior.

Likely interviewer follow-ups

  • Why does docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1 address Scheduling here rather than through application code?
  • How would you distinguish healthy Desired State from the failure “describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests” using drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns?
  • When would this trade-off-“Declarative reconciliation improves scale and recovery; controllers require stable APIs, observability and well-defined failure behavior”-justify a different Self-Healing design?
Interview tip: Give one concrete operation-docker service create --replicas 3 --constraint node.labels.zone==a --limit-cpu .5 --name api api:2.1-and one proof-drain or stop one node, inspect service convergence and confirm traffic remains after the desired replica count returns. Then name the boundary: describing self-healing as “it never goes down,” or relying on desired replicas without readiness and resource requests.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Orchestration Concepts (Scheduling, Self-Healing, Desired State) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Limitations of Single-Host Docker in Large-Scale Production
Next topic
Docker Swarm Basics (Managers, Workers, Services & Stacks)