0
0
Dockerdevops~10 mins

Container orchestration in production in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Container orchestration in production
Define container images
Create container specs
Deploy to orchestration platform
Platform schedules containers
Monitor container health
Scale containers up/down
Handle failures & restart
Update containers with zero downtime
This flow shows how container orchestration manages container deployment, scaling, health, and updates automatically in production.
Execution Sample
Docker
docker service create --name webapp --replicas 3 nginx

docker service ls

docker service ps webapp

docker service scale webapp=5
This code creates a service with 3 nginx containers, lists services, shows container tasks, then scales the service to 5 containers.
Process Table
StepCommandActionResult/Output
1docker service create --name webapp --replicas 3 nginxCreate a service named 'webapp' with 3 nginx containersService 'webapp' created with 3 replicas
2docker service lsList all running servicesID NAME MODE REPLICAS IMAGE xyz webapp replicated 3/3 nginx:latest
3docker service ps webappShow tasks (containers) for 'webapp'ID NAME NODE DESIRED STATE CURRENT STATE abc webapp.1 node1 Running Running 2 minutes def webapp.2 node2 Running Running 2 minutes ghi webapp.3 node3 Running Running 2 minutes
4docker service scale webapp=5Scale 'webapp' service to 5 containerswebapp scaled to 5 replicas
5docker service lsList services after scalingID NAME MODE REPLICAS IMAGE xyz webapp replicated 5/5 nginx:latest
6docker service ps webappShow updated tasks for 'webapp'ID NAME NODE DESIRED STATE CURRENT STATE abc webapp.1 node1 Running Running 5 minutes def webapp.2 node2 Running Running 5 minutes ghi webapp.3 node3 Running Running 5 minutes jkl webapp.4 node1 Running Running 1 minute mno webapp.5 node2 Running Running 1 minute
7docker service update --image nginx:1.21 webappUpdate service to new image versionService 'webapp' updated to image nginx:1.21 with rolling update
8docker service ps webappShow tasks during updateSome tasks restarting with new image, old tasks stopping
9docker service lsFinal service stateID NAME MODE REPLICAS IMAGE xyz webapp replicated 5/5 nginx:1.21
10ExitAll containers running updated image, scaling and update completeOrchestration successful
💡 All containers are running the updated image with desired replicas; orchestration tasks complete.
Status Tracker
VariableStartAfter Step 1After Step 4After Step 7Final
replicas03555
image_versionnonenginx:latestnginx:latestnginx:1.21nginx:1.21
service_statusnonecreatedscaledupdatingrunning updated
Key Moments - 3 Insights
Why does the number of replicas increase after the scale command?
Because the 'docker service scale' command changes the desired number of container replicas from 3 to 5, as shown in execution_table step 4 and 5.
How does the orchestration platform update containers without downtime?
It performs a rolling update by restarting containers one by one with the new image, keeping others running, as seen in steps 7 and 8.
What happens if a container fails during orchestration?
The platform automatically restarts the failed container to maintain the desired state, though this is implied in the flow and not shown explicitly in the table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 4. What does the command do?
ACreates a new service with 5 replicas
BScales the existing service to 5 replicas
CDeletes the service named webapp
DUpdates the service image to nginx:1.21
💡 Hint
Check the 'Action' and 'Result/Output' columns at step 4 in the execution_table.
At which step does the service image version change?
AStep 1
BStep 4
CStep 7
DStep 9
💡 Hint
Look at the 'Command' and 'Result/Output' columns describing image update in the execution_table.
According to variable_tracker, what is the number of replicas after step 7?
A5
B0
C3
D7
💡 Hint
Check the 'replicas' row and the 'After Step 7' column in variable_tracker.
Concept Snapshot
Container orchestration manages multiple containers automatically.
Use commands like 'docker service create' to deploy.
Scale with 'docker service scale' to adjust replicas.
Update images with 'docker service update' for zero downtime.
Orchestration handles failures and keeps desired state.
Full Transcript
Container orchestration in production means managing many containers automatically. First, you create a service with a set number of container replicas. The orchestration platform schedules these containers on nodes. You can scale the number of containers up or down with a simple command. When updating the container image, the platform performs a rolling update to avoid downtime by restarting containers one at a time. It also monitors container health and restarts any that fail to keep the service running smoothly. This process ensures your application stays available and updated without manual intervention.