Tool.Yun
Công cụ cho nhà phát triển.
Bộ chuyển đổi dBm mW
Bộ chuyển đổi nhiều đơn vị
Bộ chuyển đổi số La Mã
Bộ chuyển đổi thuộc tính
Bộ chuyển đổi đơn vị lưu trữ dữ liệu
Bộ chuyển đổi định dạng biến Env
Bộ mã hóa/giải mã mảng Hex Base64
Chuyển đổi cơ số số nguyên
Chuyển đổi ký tự Unicode sang thực thể Java
Chuyển đổi văn bản thành Unicode
Chuyển đổi văn bản thành nhị phân ASCII
Csv sang Dữ liệu
Công cụ chuyển đổi tọa độ địa lý
Excel thành dữ liệu
Tiêu thụ năng lượng và chi phí máy tính
Torrent đến Nam châm
Trình chuyển đổi tệp Base64
Trình chuẩn hóa email
Trình mã hóa/giải mã chuỗi Base64
Tạo ULID
Bánh xe may mắn
Người lăn xúc xắc
Người lật đồng xu
Người nhặt thẻ
Bộ chuyển đổi Docker Compose sang Docker run
Bộ chuyển đổi định dạng Docker Compose
Chuyển đổi lệnh docker run thành tệp docker-compose
Docker Compose thành Quadlets
Docker Compose thành tệp .env
Docker chạy đến Quadlets
Docker chạy đến kubernetes
Docker compose thành Kubernetes
Docker kiểm tra để chạy Docker
Nhãn Docker Pangolin
Traefik Docker Compose Maker
Trình tạo RBAC Kubernetes
Trình tạo nhãn Dockerfile
Trình tải xuống ảnh Docker
Trình xác thực Docker Compose
Bộ chuyển đổi chữ hoa RMB
Bộ chuyển đổi tiền tệ
Công cụ chuyển đổi lịch
Công cụ tìm kiếm ISO 639
Công cụ tìm kiếm mã quốc gia ISO 3166
Công cụ tính toán tốc độ chạy
Giải thích lệnh Shell
Hướng dẫn chiếu sáng IES
Khả năng tương thích giấy phép phần mềm
Kiểm tra thẻ tín dụng
Kiểm tra và phân tích số IBAN
Máy tính BMI
Máy tính SLA
Trình phân tích và định dạng số điện thoại
Trình xác thực Luhn
Trình xác thực số VAT
Trình xác thực và phân tích ISBN
Tìm kiếm Unicode
Từ điển trực tuyến
Chuyển đổi Epub sang Markdown
Chuyển đổi Markdown thành dữ liệu
Chuyển đổi Markdown thành văn bản
Công cụ tạo bảng Markdown
Dán dưới dạng Markdown
HTML để đánh dấu
Markdown Lorem Ipsum
Markdown sang DOCX
Markdown sang HTML
So sánh Markdown
Trình chỉnh sửa Markdown
Trình làm đẹp bảng Markdown
Trình tạo mục lục Markdown
Xem trước Markdown
tools.markdown-format-converter.name
Bộ biến đổi màu hình ảnh
Bộ chuyển đổi HEIC
Bộ chuyển đổi ICO/PNG
Bộ chuyển đổi định dạng hình ảnh
Chuyển đổi GIF sang MP4
Cắt ảnh
Dấu mờ
Ghi lại camera
Hình ảnh sang SVG (potrace)
OCRize hình ảnh và PDF
So sánh hình ảnh
Thay đổi kích thước hình ảnh
Trình xem trước SVG
Trình đọc chất lượng hình ảnh EXIF/Siêu dữ liệu/GPS/JPEG
Xóa EXIF
Xóa nền ảnh
Bộ chuyển đổi JS sang JSON
Bộ chuyển đổi JSON sang JS
Bộ chuyển đổi chuỗi JSON
CSV sang JSON
Chuyển đổi JSON sang TOML
Chuyển đổi JSON sang TS
Chuyển đổi JSON sang YAML
Chuyển đổi JSON sang tệp .env
Chuyển đổi JSON thành CSV
Chuyển đổi Json sang SQL DDL
Chuyển đổi ObjGen sang JSON
Giảm kích thước JSON
Gói tin nhắn thành JSON
JSON sang C#
JSON sang MessagePack
JSON sang XML
JSON sang thực thể Java
JSON thành Dữ liệu
JSON thành đối tượng
JSON để đi
Json Escaper/Unescaper
Json sang Python
Json thành Schema
Json thành mảng PHP
Mã Json sang PHP
PHP-Mảng thành JSON
So sánh JSON
Sáp nhập JSON
Sắp xếp JSON
Truy vấn JSON
Trình kiểm tra Jq/JSONPath
Trình kiểm tra lỗi JSON
Trình làm phẳng/gỡ phẳng JSON
Trình phân tích kích thước JSON
Trình soạn thảo JSON
tools.json-patch.name
Định dạng và làm đẹp JSON
Bộ chuyển đổi UUID
Máy tạo NanoID
Máy tạo mã PIN
Máy tạo số ngẫu nhiên
Trình tạo BIP39 passphrase
Trình tạo Numeronym
Trình tạo UUID
Trình tạo mã thông báo
Trình tạo mật khẩu
Trình tạo mật khẩu Diceware
Tạo mã OTP
Argon2 Hasher
Bcrypt
Bộ chuyển đổi chứng chỉ SSL
Bộ mã hóa/giải mã Bech32
Chia sẻ bí mật của Shamir
File Hasher
Giải mã JWT
Giải mã hầm chứa Ansible
Máy phát điện JWT
Máy tính CRC
Máy tạo HMAC
Mã hóa / giải mã văn bản
Mã hóa PGP
Mã hóa RSA
Mã hóa chuỗi Jasypt
Mã hóa tập tin PGP
Mã hóa văn bản
Mật mã AGE
Người ký và xác minh RSA/DSA/ECDSA
Niceware Bytes thành Mật khẩu
PGP keygen
Paseto/PASERK Công cộng/Tư nhân
Paseto/PASERK Địa phương
Trình phân tích chứng chỉ/khóa
Trình phân tích cú pháp SAML
Trình tạo CSR
Trình tạo chứng chỉ X509
Trình tạo cặp khóa ECDSA
Trình tạo cặp khóa Ed25519
Trình tạo cặp khóa RSA
Bộ giải mã mã QR
Máy tạo mã vạch
Máy đọc mã vạch
Trình tạo thông tin liên hệ QR
Trình xác thực GTIN
Tạo mã QR
Tạo mã QR WiFi
tools.epc-qrcode-generator.name
Bảng gian lận ZPool
Bộ chuyển đổi Punycode
Bộ chuyển đổi địa chỉ Ipv6
Bộ chuyển đổi địa chỉ MAC
Bộ giải mã ARPA
Bộ giải mã X-VR-SpamCause
Bộ phân tích độ mạnh mật khẩu
Bộ tuyến tính hóa lệnh Shell
Bộ tạo lệnh UFW
Bộ tạo lệnh tắt máy
Chuyển đổi địa chỉ Ipv4
Có chất khử trùng
Công cụ kiểm tra cổng TCP/UDP
Công cụ tính toán mạng con trực quan
IPv4-6/IPRange/CIDR trong IPRange/CIDR/IPMask
Kiểm tra Websocket
Kiểm tra Whois
Máy kiểm tra micrô
Máy phát WPA PSK
Máy tính Chmod
Máy tính HDD
Máy tính RAID
Máy tính RAID ZPOOL
Máy tính loại trừ mạng con IP
Máy tính mạng con IPv4
Máy tính mạng con IPv6
Máy tính phạm vi CIDR sang IP của Ipv4/6
Máy tính phạm vi IPv4/6 đến CIDR(s)
Máy tính tốc độ truyền dữ liệu
Máy tính độ tin cậy RAID
Mở rộng dải IPv4
Ping
Số cổng
Số nguyên cho IPv4/IPv6
Tra cứu địa chỉ MAC
Truy vấn DNS
Truy vấn DNS/RDAP của Cloudflare
Trình kiểm tra DNSBL
Trình liệt kê mạng con IPv4
Trình tạo Apache LogRotate
Trình tạo Crontab
Trình tạo DNS BIMI
Trình tạo DNS DKIM
Trình tạo DNS DMARC
Trình tạo DNS PTR
Trình tạo DNS SPF
Trình tạo FStab
Trình tạo HTAccess
Trình tạo Iptables
Trình tạo Option43
Trình tạo Rsync
Trình tạo cấu hình Wireguard
Trình tạo htpasswd/htaccess
Trình tạo lệnh Curl
Trình tạo số cổng ngẫu nhiên
Trình tạo địa chỉ IPv6 ULA
Trình tạo địa chỉ MAC
Trình tải xuống nhiều liên kết
Trình định dạng Nginx
Trình định dạng lệnh Shell
Tạo mã xác thực cơ bản
Vị trí địa lý IP
tools.restic-command-generator.name
tools.url-redirection-checker.name
trình tạo dòng lệnh firewalld
Địa chỉ IP của tôi
Độ mạnh của mật khẩu Zxcvbn
Ủy quyền SIP
Trình tạo biểu thức Cron
Báo thức Cron/Ngày trong tuần
Báo thức thời gian
Bộ chuyển đổi múi giờ
Bộ chuyển đổi số tuần
Chuyển đổi ngày-tháng
Máy phát điện ICAL
Máy tính ETA
Máy tính Ngày + Thời lượng
Máy tính TTL
Máy tính ngày
Máy tính thời lượng
Ngày nào?
Sáp nhập iCal
Trình phân tích tệp ICAL
Đếm ngược
Đồng hồ bấm giờ
Chuyển đổi HTML sang PDF
Giải mã và mở khóa PDF
Kiểm tra chữ ký PDF
Mã hóa PDF
Pdf Linearize/FastWeb
Trình nén PDF
Trình nối PDF
Trình trích xuất trang PDF
Trình trích xuất văn bản PDF
Bảng gian lận Bash
Bảng gian lận Jq
Bảng gian lận K8s
Bảng hướng dẫn Docker
Bảng hướng dẫn Git Semantic Commit
Bảng hướng dẫn Markdown
Bảng hướng dẫn Regex phổ biến
Bảng hướng dẫn VIM
Bảng hướng dẫn cú pháp JSONPath
Bảng hướng dẫn cú pháp XPath
Bảng hướng dẫn lệnh chmod
Bảng hướng dẫn sử dụng Nginx
Bảng hướng dẫn sử dụng Regex
Bảng hướng dẫn sử dụng bộ chọn CSS
Bảng tóm tắt PowerShell
Bảng tóm tắt các lệnh Tmux
Bảng tóm tắt các lệnh Zellij
Bảng tóm tắt lệnh màn hình
Lệnh Git
Nano CheatSheet
Phiếu gian lận Sed
Tài liệu hướng dẫn Docker Compose
Tài liệu hướng dẫn Docker SWARM
Tài liệu hướng dẫn Dockerfile
Bảng điều khiển cổng nối tiếp
Bộ chuyển đổi GZip/Deflate
Bộ chuyển đổi Middle-Endian
Bộ chuyển đổi ObjectId MongoDB
Bộ chuyển đổi SMART Raw
Bộ chuyển đổi mã hóa MIME
Bộ chuyển đổi số dấu phẩy động
Bộ giải mã EMV TLV
Bộ giải mã Outlook Safelink
Bộ giải mã URL chia sẻ Sharepoint
Bộ giải mã giao dịch ETH
Bộ mã hóa/giải mã Hex
Bộ phát hiện/giải mã ký tự văn bản
Che giấu dữ liệu nhạy cảm
Công cụ kiểm tra DNS
Công cụ kiểm tra HTTPS
Công cụ kiểm tra sự lan truyền DNS
Công cụ kiểm tra điểm ảnh chết
File Parquet Reader
Hướng dẫn nhanh đấu dây RJ45 Cat6
Máy trích xuất ID bông tuyết
Máy tính điện trở
Mở rộng URL ngắn
Thông tin Keycode
Trình phát hiện loại tệp
Trình phân tích MSG của Outlook
Trình phân tích URL
Trình phân tích báo cáo DMARC
Trình phân tích cookie
Trình phân tích email
Trình phân tích email trả lại
Trình tìm kiếm thuộc tính LDAP của ActiveDirectory
Trình tạo TCPDump
Trình tạo URL
Trình tạo lệnh Nmap
键盘测试器
Bộ chia tệp
Bộ chuyển đổi Curl
Bộ chuyển đổi báo giá
Bộ chuyển đổi tệp HEX
Bộ thoát dây
Công cụ tô sáng mã/tập lệnh
Công cụ tạo cơ sở dữ liệu
Công cụ tạo kịch bản kiểm thử tải K6
Json sang SQL INSERT
Json sang Typescript
Json thành Protobuf
Kiểm tra API
Kiểm tra giao diện người dùng Swagger
Kiểm tra thoát ANSI
Kẻ làm giả dữ liệu
Làm đẹp và thu nhỏ CSS/JS
Máy kiểm tra Picomatch
Stacktrace đẹp hơn
Trình giải mã Javascript/Trình giải nén
Trình làm xáo trộn Javascript
Trình làm đẹp Javascript
Trình soạn thảo lệnh CLI
Trình thu nhỏ SQL
Trình tạo GitIgnore
Trình tạo Mailto
Trình tạo biểu tượng yêu thích
Trình tạo bí mật Django
Trình tạo bảng cơ sở dữ liệu
Trình tạo chuỗi kết nối cơ sở dữ liệu
Trình tạo meta Open Graph
Trình tạo tham số SQL
Trình tạo thuộc tính Git
Định dạng và làm đẹp SQL
Đồng hồ bấm giờ Pomodoro
Chuyển đổi TOML thành JSON
Chuyển đổi TOML thành YAML
TOML Linter
Bộ chuyển đổi định dạng toán học
Công cụ trực quan hóa đường cong lượng giác/phương trình
Máy tính nhị phân
Máy tính tiền boa
OCR toán học
Trình đánh giá toán học
Máy tính khấu hao
Bộ chia lời nhắc AI
Bộ chuyển đổi bố cục bàn phím
Bộ chuyển đổi mã Morse
Bộ chuyển đổi rune
Bộ chọn biểu tượng cảm xúc
Bộ mã hóa/giải mã mã thông báo GPT
Chuyển đổi chữ hoa/chữ thường
Chuyển đổi văn bản thành bảng chữ cái NATO
Công cụ ước tính mã thông báo GPT
Gói tập tin cho AI
Hình ảnh thành nghệ thuật ASCII
JSON sang TOON
Kiểm tra I và L
Kiểm tra Regex
Máy phát điện/Biểu ngữ Zalgo
Máy tính Levenshtein
Máy tạo văn bản Lorem ipsum
Mã hóa chuỗi
Người chia sẻ liên kết xã hội
Phím Tab để chuyển đến khoảng trắng
RSVP Reader
So sánh danh sách
So sánh phông chữ
So sánh văn bản
Sơ đồ cấu trúc thư mục
TOON sang JSON
Thống kê văn bản
Trình chuyển đổi danh sách
Trình chọn dòng ngẫu nhiên
Trình dịch văn bản
Trình thay thế văn bản thông minh và ngắt dòng
Trình tìm kiếm dòng trùng lặp
Trình tạo lệnh Sed
Trình tạo trích dẫn
Trình tạo văn bản nghệ thuật ASCII
Trình định dạng Unicode
Trích xuất văn bản từ HTML
Từ ngữ riêng biệt
Unicode sang GSM-7
Văn bản thành tên Unicode
Xuất khẩu nàng tiên cá
Bộ chuyển đổi gia tốc
Bộ chuyển đổi lưu lượng thể tích
Bộ chuyển đổi nhiệt độ
Bộ chuyển đổi năng lượng thực phẩm
Bộ chuyển đổi tiền tố SI
Bộ chuyển đổi tần số
Bộ chuyển đổi tốc độ
Bộ chuyển đổi điện
Bộ chuyển đổi đơn vị chiều dài
Bộ chuyển đổi đơn vị diện tích
Bộ chuyển đổi đơn vị góc
Bộ chuyển đổi đơn vị khối lượng
Bộ chuyển đổi đơn vị lực
Bộ chuyển đổi đơn vị năng lượng
Bộ chuyển đổi đơn vị thể tích
Bộ chuyển đổi đơn vị áp suất
Bộ chuyển đổi độ rọi
Máy tính thể dục
Bánh xe màu
Bộ chuyển đổi CSS XPath
Bộ chuyển đổi pixel REM
Bộ chuyển đổi đơn vị CSS
Chuyển đổi HTML sang XHTML
Chuyển đổi HTML sang dữ liệu
Chuyển đổi chuỗi thành slug
Hình ảnh sang CSS
Kiểm tra độ tương phản màu
Loại Mime
Mã hóa/giải mã chuỗi định dạng URL
Mã trạng thái HTTP
Thay thế các ký tự HTML
Thông tin thiết bị
Trình bắt URL
Trình chuyển đổi màu
Trình dọn dẹp HTML
Trình dọn dẹp URL
Trình làm đẹp CSS
Trình làm đẹp HTML
Trình phân tích User-agent
Trình soạn thảo HTML WYSIWYG
Trình thu nhỏ HTML
Trình tạo Gradient CSS
Trình tạo URL UTM
Trình tạo hình ảnh SVG giả định
Trình tạo đoạn tìm kiếm văn bản URL
Chuyển đổi ObjGen sang HTML
Kiểm tra XPath
Kiểm tra XSLT
Trình kiểm tra lỗi XML
XML sang JSON
Định dạng XML
Sáp nhập YAML
Trình chuyển đổi YAML sang JSON
Trình làm phẳng/bật YAML
YAML sang TOML
Định dạng và làm đẹp YAML
Máy tính khoảng cách địa lý
Máy tính phần trăm
Máy tính tỷ lệ khung hình
Trình tạo bảng đánh giá

Tài liệu hướng dẫn Docker SWARM

Tài liệu hướng dẫn chế độ Docker Swarm

Docker Swarm mode is Docker’s native clustering and orchestration solution. It turns a group of Docker hosts into a single virtual system with high availability, load balancing and a declarative deployment model — using the CLI you already know.

  • Built-in orchestration with a declarative service model
  • Rolling updates and one-command rollback
  • Self-healing: failed replicas are rescheduled automatically
  • Secure node-to-node communication over mutual TLS, rotated automatically
  • Secrets and configs distributed straight from the cluster store

ℹ️ Swarm does not auto-scale on load. Replica counts are set manually with --replicas or docker service scale.

🧱 Concepts

TermWhat it is
NodeA Docker engine that joined the swarm — a manager or a worker
ManagerKeeps cluster state via Raft, schedules tasks, serves the API
WorkerRuns tasks only; has no view of the cluster state
ServiceThe declaration of what should run (image, replicas, ports, …)
TaskOne container slot of a service, scheduled onto a node
StackA group of services deployed together from a Compose file

📌 Swarm Initialization

# initialize a swarm; this node becomes the first manager
docker swarm init

# pick the interface to advertise on multi-homed hosts
docker swarm init --advertise-addr <manager-ip>

# address pool for the overlay networks
docker swarm init --default-addr-pool 10.20.0.0/16

# print the command a worker needs to join
docker swarm join-token worker

# print the command a manager needs to join
docker swarm join-token manager

# run on the joining node
docker swarm join --token <token> <manager-ip>:2377

# rotate a token, invalidating the old one
docker swarm join-token --rotate worker

# leave the swarm (on a worker)
docker swarm leave

# leave on a manager, or on the last node
docker swarm leave --force

# keep fewer terminated tasks per service
docker swarm update --task-history-limit 5

# lifetime of the node certificates
docker swarm update --cert-expiry 720h

# rotate the swarm certificate authority
docker swarm ca --rotate

🔌 Ports that must be open between nodes

PortProtocolUsed for
2377TCPCluster management (managers only)
7946TCP + UDPNode discovery and gossip
4789UDPOverlay network data plane (VXLAN)
IP protocol 50 (ESP)—Only with encrypted overlay networks

👥 Node Management

# list the nodes of the swarm
docker node ls

# filter by role, id, name, label, membership
docker node ls --filter role=manager

# readable summary of one node
docker node inspect <node> --pretty

# a single field via a Go template
docker node inspect -f '{{.Status.State}}' <node>

# worker  → manager
docker node promote <node>

# manager → worker
docker node demote <node>

# move tasks off and stop scheduling new ones
docker node update --availability drain <node>

# keep running tasks, schedule nothing new
docker node update --availability pause <node>

# bring a drained or paused node back
docker node update --availability active <node>

# label a node for placement constraints
docker node update --label-add env=production <node>

# remove a label again
docker node update --label-rm env <node>

# tasks running on a node
docker node ps <node>

# remove a node that already left
docker node rm <node>

# remove an unreachable node
docker node rm --force <node>

💡 Drain a node before maintenance (--availability drain), then set it back to active. Swarm reschedules the tasks for you.

🧠 Manager Nodes & Raft

Managers orchestrate tasks, maintain the cluster state through Raft consensus and serve the API. Several managers give you high availability, but only one is the leader at a time.

⚠️ Use an odd number of managers (3, 5 or 7). Raft tolerates (N-1)/2 failures — 3 managers survive 1 loss, 5 survive 2. Beyond 7 the consensus overhead outweighs the benefit.

# swarm and Raft state of the local node
docker info

# details of the current node, manager status included
docker node inspect self --pretty

# encrypt the Raft logs at rest
docker swarm update --autolock=true

# unlock a manager after a restart
docker swarm unlock

# show the current unlock key
docker swarm unlock-key

# rotate it
docker swarm unlock-key --rotate

📦 Service Management

# create a service
docker service create --name <service> <image>

# create a service with a fixed replica count
docker service create --name <service> --replicas <n> <image>

# create a global service: one task on every node
docker service create --name <service> --mode global <image>

# list services
docker service ls

# filter the list
docker service ls --filter name=<service>

# readable service definition
docker service inspect <service> --pretty

# tasks and the nodes they run on
docker service ps <service>

# change the replica count
docker service scale <service>=<n>

# scale several services at once
docker service scale <svc-a>=3 <svc-b>=5

# roll out a new image
docker service update --image <new-image> <service>

# redistribute tasks without changing anything
docker service update --force <service>

# go back to the previous definition
docker service rollback <service>

# follow the logs of every task
docker service logs -f <service>

# recent output only
docker service logs --tail 100 --since 10m <service>

# remove a service
docker service rm <service>

Changing a running service

# add or replace an environment variable
docker service update --env-add KEY=value <service>

# remove one
docker service update --env-rm KEY <service>

# publish another port
docker service update --publish-add 8080:80 <service>

# stop publishing it
docker service update --publish-rm 8080 <service>

# attach a volume
docker service update --mount-add type=volume,src=data,dst=/data <service>

# detach it again, by target path
docker service update --mount-rm /data <service>

# add a placement constraint
docker service update --constraint-add 'node.labels.env==prod' <service>

# at most one task per node
docker service update --replicas-max-per-node 1 <service>

# change the resource limits
docker service update --limit-memory 512m --reserve-memory 256m <service>

🔁 Replicas & Modes

Replicas define how many instances of a service run across the swarm. Swarm spreads them over the available nodes and reschedules them when a task or a node fails.

ModeFlagBehaviour
Replicated--mode replicated (default)Run exactly --replicas tasks, anywhere they fit
Global--mode globalExactly one task per eligible node
Replicated job--mode replicated-jobRun --replicas tasks to completion
Global job--mode global-jobRun one task to completion on every node
# five tasks
docker service create --replicas 5 --name myapp myimage

# scale the same service up to ten
docker service scale myapp=10

# one per node
docker service create --mode global --name agent myimage

# batch job: 20 tasks in total, 4 running at a time
docker service create --mode replicated-job --replicas 20 \
  --max-concurrent 4 --name migrate myimage

🐝 Tasks & Containers

A task is a single container slot managed by Swarm; it maps to one container on one node and is never moved — a failed task is replaced by a new one.

# tasks of a service, with their node
docker service ps <service>

# full error messages — start debugging here
docker service ps --no-trunc <service>

# hide the terminated tasks
docker service ps -f "desired-state=running" <service>

# tasks on one node
docker node ps <node>

# containers on the current node
docker container ls

# low-level details of one container
docker container inspect <container-id>
Task stateMeaning
NEW / PENDINGAccepted, waiting for a node that satisfies the constraints
ASSIGNED / PREPARINGSent to a node, image being pulled
STARTING / RUNNINGThe container is starting or up
COMPLETEA job task finished successfully
FAILEDThe container exited with an error
SHUTDOWNStopped on purpose (update, drain, scale down)
REJECTEDThe node refused the task (missing image, bad mount)
ORPHANEDThe node has been unreachable too long

🎯 Placement

docker service create --constraint 'node.role==worker' --name web nginx

docker service create --constraint 'node.labels.env==production' --name api myimage

docker service create --placement-pref 'spread=node.labels.zone' --name web nginx

docker service create --replicas-max-per-node 1 --name web nginx
ExpressionMatches
node.rolemanager or worker
node.hostnameThe node’s hostname
node.idThe node’s ID
node.labels.<key>A label set with docker node update --label-add
engine.labels.<key>A label set in the engine’s daemon.json
node.platform.os / node.platform.archlinux, windows / amd64, arm64

🌐 Networking

An overlay network is a virtual network spanning multiple Docker hosts. Containers on different nodes talk as if they were on the same L2 segment, with DNS-based service discovery built in.

# create an overlay network
docker network create --driver overlay <network>

# encrypt the data plane too
docker network create --driver overlay --opt encrypted <network>

# let standalone containers join
docker network create --driver overlay --attachable <network>

# list networks
docker network ls

# attached services and containers
docker network inspect <network>

# attach at creation time
docker service create --name <service> --network <network> <image>

# attach an existing service
docker service update --network-add <network> <service>

# detach it again
docker service update --network-rm <network> <service>

Publishing ports

# routing mesh (ingress)
docker service create --publish 8080:80 --name web nginx

# host port, no mesh
docker service create --publish mode=host,target=80,published=8080 --name web nginx
ModeBehaviour
ingress (default)Every node accepts the port and load-balances to the tasks
hostThe port is published only on nodes running a task — no mesh, no extra hop

🔄 Rolling Updates & Rollback

docker service create \
  --name web \
  --replicas 5 \
  --update-parallelism 2 \
  --update-delay 10s \
  --update-failure-action rollback \
  --update-monitor 30s \
  nginx:1.25

# trigger the rolling update
docker service update --image nginx:1.26 web

# return to the previous definition
docker service rollback web
FlagDescription
--update-parallelismHow many tasks are updated at once (0 = all)
--update-delayPause between batches
--update-failure-actionpause (default), continue or rollback
--update-monitorHow long a task is watched before it counts as healthy
--update-orderstop-first (default) or start-first
--rollback-parallelismSame knobs for the rollback path (--rollback-delay, --rollback-monitor, --rollback-failure-action, --rollback-order)

🩺 Health Checks

Swarm reschedules a task as soon as its health check fails, so an update never marks a broken image as healthy.

docker service create \
  --name api \
  --health-cmd 'curl -f http://localhost:8080/health || exit 1' \
  --health-interval 10s \
  --health-timeout 3s \
  --health-retries 3 \
  --health-start-period 30s \
  myimage

🔐 Secrets

Secrets are encrypted in the Raft log and mounted into the container as in-memory files under /run/secrets/.

# create from a file
docker secret create db_password ./db_password.txt

# create from stdin
echo "s3cr3t" | docker secret create db_password -

# list secrets
docker secret ls

# metadata only — never the value
docker secret inspect db_password

# attach a secret; it appears at /run/secrets/db_password
docker service create --name db --secret db_password postgres:16

# ...or mount it at a custom path with a fixed mode
docker service create --name db \
  --secret source=db_password,target=/run/secrets/pg_pw,mode=0400 postgres:16

# only possible when no service uses it
docker secret rm db_password

Rotating a secret — create the new one, swap it, then drop the old one:

echo "n3w-s3cr3t" | docker secret create db_password_v2 -

docker service update \
  --secret-rm db_password \
  --secret-add source=db_password_v2,target=db_password \
  db

docker secret rm db_password

🔑 Configs

Configs work like secrets but are not encrypted at rest — use them for non-sensitive files such as nginx.conf.

# create a config
docker config create my_nginx_conf ./nginx.conf

# list configs
docker config ls

# metadata and the stored content
docker config inspect my_nginx_conf

# mount a config at a specific path
docker service create \
  --name web \
  --config source=my_nginx_conf,target=/etc/nginx/nginx.conf \
  nginx

# swap in a new version of the config
docker service update \
  --config-rm my_nginx_conf \
  --config-add source=my_nginx_conf_v2,target=/etc/nginx/nginx.conf \
  web

# only when no service uses it
docker config rm my_nginx_conf

📚 Stacks

A stack is a group of related services deployed together from a Compose file — the standard production workflow for Swarm.

# deploy or update a stack
docker stack deploy -c stack.yaml mystack

# pass your registry credentials along
docker stack deploy -c stack.yaml --with-registry-auth mystack

# remove services no longer in the file
docker stack deploy -c stack.yaml --prune mystack

# list stacks
docker stack ls

# services of a stack
docker stack services mystack

# tasks of a stack
docker stack ps mystack

# tasks of a stack, with full error messages
docker stack ps --no-trunc mystack

# print the merged, resolved file
docker stack config -c stack.yaml

# remove the whole stack
docker stack rm mystack

Stacks honour the deploy: block of the Compose file (replicas, placement, resources, restart policy, update config). build:, top-level restart: and depends_on: are ignored.

🧯 Troubleshooting

# the error column tells you why a task died
docker service ps --no-trunc <service>

# application output of every task
docker service logs --tail 200 <service>

# is a node Down or Unreachable?
docker node ls

# what was actually deployed
docker service inspect --pretty <service>

# live stream of orchestration events
docker events --filter type=service
SymptomUsual cause
Task stuck in PENDINGNo node satisfies the constraints, ports, or resource reservations
no suitable nodePlacement constraint or --replicas-max-per-node cannot be met
Task loops FAILED → STARTINGThe container exits immediately — read docker service logs
REJECTED with an image errorThe image is missing on that node; use --with-registry-auth for private registries
Service unreachable from other nodesPorts 7946/4789 blocked, or the services are not on the same overlay network

🛠 Common Flags Reference

docker service create / docker service update

FlagDescription
--replicasNumber of tasks for a replicated service
--modereplicated (default), global, replicated-job, global-job
--publishPort mapping (<published>:<target>, or mode=host,...)
--mountAttach a volume or bind mount
--networkAttach to an overlay network
--constraintPlacement rule, e.g. node.role==worker
--placement-prefSpread tasks, e.g. spread=node.labels.zone
--replicas-max-per-nodeCap the tasks of this service per node
--limit-cpu / --limit-memoryHard resource limits
--reserve-cpu / --reserve-memoryResources reserved for scheduling
--secret / --configAttach a secret or a config
--env / --env-fileEnvironment variables
--restart-conditionnone, on-failure or any (default)
--health-cmd and friendsOverride the image health check
--with-registry-authForward registry credentials to the nodes

📄 Example: Production-style Web Service

docker service create \
  --name web \
  --replicas 3 \
  --publish 80:80 \
  --network webnet \
  --constraint 'node.role==worker' \
  --constraint 'node.labels.env==production' \
  --placement-pref 'spread=node.labels.zone' \
  --update-parallelism 1 \
  --update-delay 10s \
  --update-failure-action rollback \
  --update-order start-first \
  --limit-memory 512m \
  --reserve-memory 256m \
  --restart-condition any \
  nginx:1.25

📚 Resources

  • Swarm mode overview
  • Swarm services
  • Manage secrets
  • Manage configs
  • Stack file reference (Compose Spec deploy:)
  • docker service create CLI reference