Docker SwarmDocker自动化Docker容器

Docker Swarm 入门:节点管理

2018-01-10  本文已影响347人  Anoyi

文/Anoyi

► Docker Swarm 集群节点管理常用操作

1、查看当前集群节点列表

在 Manager 上执行如下命令

docker node ls

结果如下

ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
3fff9l59dvn5jvot2s27gf9n2 *   ManagerX            Ready               Active              Leader
4byjmtcm1ag8qffxjwnhwsf4l     WorkerA             Ready               Active
sks1qb0zqlaetmpsqfj5tfx56     WorkerB             Ready               Active

AVAILABILITY 的三种状态:

MANAGER STATUS 的三种状态

2、检查单个节点

在 Manager 上执行如下命令

docker node inspect <NODE-ID>

默认结果是 JSON 格式,加上 --pretty 变为普通格式

ocker@ManagerX:~$ docker node inspect ManagerX --pretty
ID:         3fff9l59dvn5jvot2s27gf9n2
Hostname:               ManagerX
Joined at:              2018-01-10 06:23:26.309570091 +0000 utc
Status:
 State:         Ready
 Availability:          Active
 Address:       192.168.99.100
Manager Status:
 Address:       192.168.99.100:2377
 Raft Status:       Reachable
 Leader:        Yes
Platform:
 Operating System:  linux
 Architecture:      x86_64
Resources:
 CPUs:          1
 Memory:        995.9MiB
Plugins:
 Log:       awslogs, fluentd, gcplogs, gelf, journald, json-file, logentries, splunk, syslog
 Network:       bridge, host, macvlan, null, overlay
 Volume:        local
Engine Version:     18.01.0-ce-rc1

3、更新节点

3.1、改变节点的可用性(availability),示例

docker node update --availability drain WorkerA

3.2、添加/移除标签元数据,示例

docker node update --label-add foo --label-add bar=baz WorkerA

3.3、升级/降级节点,示例

[升级] docker node promote WorkerA
[降级] docker node demote WorkerA
上一篇下一篇

猜你喜欢

热点阅读