Docker Swarm
Docker Swarm
Docker's built-in container orchestration. Simpler than Kubernetes. Suited to small clusters.
Docker Swarm
Docker's built-in container orchestration. Simpler than Kubernetes. Suited to small clusters.
Docker Swarm is a native container orchestration tool built into Docker. It clusters multiple Docker hosts into a single virtual host to distribute and manage containers. It has been integrated into Docker Engine since Docker 1.12 (2016).
The architecture consists of Manager nodes (cluster management, scheduling) and Worker nodes (running containers). Manager state is synchronized with the Raft consensus algorithm, and high availability is secured with at least 3 Managers. Deployment is done per Service, and automatic load balancing is supported.
Compared to Kubernetes, it has a lower learning curve and simpler configuration. docker-compose.yml can be deployed with docker stack deploy, so it is familiar to existing Docker users. However, its ecosystem and community are limited in scale compared to Kubernetes.
In practice, it is suitable for small teams, simple services, and rapid prototyping. Swarm is efficient up to a scale of 10-20 containers, and when the scale grows, migration to Kubernetes is considered. It is also used to build test environments within CI/CD pipelines.
# Swarm 클러스터 초기화 및 관리
docker swarm init --advertise-addr 192.168.1.10
docker swarm join-token worker # Worker 조인 토큰 확인
docker swarm join-token manager # Manager 조인 토큰 확인
# 노드 관리
docker node ls # 노드 목록
docker node promote worker-1 # Worker를 Manager로 승격
docker node update --availability drain manager-2 # 유지보수 모드
# docker-compose.yml (Stack 배포용)
version: '3.8'
services:
web:
image: nginx:alpine
deploy:
replicas: 3
update_config:
parallelism: 1
delay: 10s
failure_action: rollback
rollback_config:
parallelism: 1
restart_policy:
condition: on-failure
max_attempts: 3
resources:
limits:
cpus: '0.5'
memory: 256M
ports:
- "80:80"
networks:
- webnet
api:
image: myapp/api:latest
deploy:
replicas: 2
placement:
constraints:
- node.role == worker
secrets:
- db_password
networks:
- webnet
networks:
webnet:
driver: overlay
secrets:
db_password:
external: true
# Stack 배포 및 관리
docker stack deploy -c docker-compose.yml myapp
docker stack services myapp # 서비스 목록
docker service scale myapp_web=5 # 스케일 조정
docker service logs myapp_api -f # 로그 확인
Senior: "How about setting up the development environment quickly with Swarm and running production on Kubernetes?"
Junior: "Sounds good. Since we can deploy the docker-compose file to swarm as is, setting up the development environment will be much faster."
Interviewer: "Please compare and explain Docker Swarm and Kubernetes."
Candidate: "Swarm is built into Docker, so its configuration is simple and its learning curve is low. Kubernetes is feature-rich and has a large ecosystem, but it is complex. Swarm is suitable for small projects, and Kubernetes for large-scale production."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Reviewer: "There is only one Manager node. Isn't that a single point of failure?"
Developer: "You're right. In the production environment, we will set up HA with 3 Managers. Since it's for development, I left it at 1 for now."