You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker Swarm Leader节点故障后如何修改advertise-addr及解决节点操作问题

Fixing Your Swarm Cluster & Addressing advertise-addr Questions

Let's walk through this scenario step by step—first resolving the immediate issues, then tackling the advertise-addr question.

Step 1: Clean Up the Failed Manager Node (M1)

Right now, M1 is in a Down state but still registered in the cluster. This stale entry can block operations like promoting workers or re-joining nodes. On either M2 or M3 (your active managers), run:

docker node ls

You’ll see M1 marked as Down. Remove it from the cluster with:

docker node rm M1

This clears the dead node record and unblocks subsequent actions.

Step 2: Promote a Worker to Manager

With 2 active managers, you still meet the Raft quorum requirement (majority of the original 3-node manager pool), so you can safely promote a worker to restore a 3-manager cluster (far more resilient for future failures). On M2/M3, run:

docker node promote W1

Verify the change with docker node ls—W1 should now show Manager Status: Reachable.

Step 3: Re-Join M1 to the Cluster

If M1’s hardware/network issue is fixed, get it back into the swarm:

  1. On M1, wipe any leftover swarm configuration (if it’s still stuck in a broken swarm state):
    docker swarm leave --force
    
  2. On your active manager (e.g., M2), generate a manager join token:
    docker swarm join-token manager
    
  3. Copy the output command (looks like docker swarm join --token <TOKEN> <MANAGER-IP>:2377) and run it on M1. This adds M1 back as a functional manager.

Can You Update the Swarm advertise-addr?

First, a critical clarification: advertise-addr is a per-node setting, not a cluster-wide configuration. The initial docker swarm init --advertise-addr <M1-IP> only sets M1’s advertise-addr—each node uses its own address for inter-swarm communication.

To update a node’s advertise-addr, you need to re-join it to the swarm with the new address:

  1. For a manager node (e.g., M1):
    • Demote it to a worker first (from an active manager):
      docker node demote M1
      
    • On M1, leave the swarm:
      docker swarm leave
      
    • Get a worker join token from an active manager:
      docker swarm join-token worker
      
    • Re-join M1 with the new advertise-addr:
      docker swarm join --token <WORKER-TOKEN> <MANAGER-IP>:2377 --advertise-addr <NEW-M1-IP>
      
    • Promote M1 back to manager:
      docker node promote M1
      
  2. For a worker node (e.g., W2), the process is simpler—just leave and re-join with the --advertise-addr flag (no demotion/promotion needed).

Note: If your clients were previously connecting exclusively to M1’s IP for swarm operations, you should update them to use any active manager’s IP (or set up a load balancer across all managers) instead of relying on a single node’s address.

内容的提问来源于stack exchange,提问作者Arun Jose

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:12:13