Table of Contents
- Verify Cluster Status
- Create Your First Service
- Inspect Tasks and Service Details
- View Service Logs
- Self-Healing Demonstration
- Remove the Service
- Scale Services
- Rolling Updates
- Rollback
- Quick Command Reference
1. Verify Cluster Status
Ensure your 6-node Swarm is healthy and managers/workers are all Ready:Always confirm that at least one manager node is in Leader status before proceeding.
2. Create Your First Service
Deploy a simple HTTP server using thehttpd:alpine image on port 80:
3. Inspect Tasks and Service Details
List the tasks (containers) forfirst-service:
4. View Service Logs
Stream logs to troubleshoot or verify startup:5. Self-Healing Demonstration
Swarm automatically replaces failed tasks to maintain the desired replica count.- On a worker, find and remove the container:
- Back on a manager, confirm Swarm recreated it:
Swarm will detect that the replica count is below the desired state and launch a new task immediately.
6. Remove the Service
Clean up by removing the service and all its tasks:7. Scale Services
Run multiple replicas behind Swarm’s built-in load balancer to ensure zero downtime.a. Create a Service with Three Replicas
b. Scale Up to Five Replicas
c. Scale Down to Three Replicas
8. Rolling Updates
Perform seamless image upgrades without stopping traffic.- View current image:
- Update to a new tag (e.g.,
httpd:2): - Monitor rollout:
During rolling updates, verify your application’s health checks to avoid cascading failures.