docker swarm 使用说明

2023-05-16


docker swarm 使用说明

 

 

**********************

swarm 命令:管理集群

 

docker swarm command

[root@centos ~]# docker swarm --help

Usage:	docker swarm COMMAND

Manage Swarm

Commands:
  ca          Display and rotate the root CA
  init        Initialize a swarm
  join        Join a swarm as a node and/or manager
  join-token  Manage join tokens
  leave       Leave the swarm
  unlock      Unlock swarm
  unlock-key  Manage the unlock key
  update      Update the swarm

Run 'docker swarm COMMAND --help' for more information on a command.

init:初始化集群

join:节点加入集群

leave:节点离开集群

update:更新集群

 

 

******************

docker swarm init

 

命令格式:docker swarm init [options]

[root@centos ~]# docker swarm init --help

Usage:	docker swarm init [OPTIONS]

Initialize a swarm

Options:
      --advertise-addr string                  Advertised address (format: <ip|interface>[:port])
      --autolock                               Enable manager autolocking (requiring an unlock key to start a stopped manager)
      --availability string                    Availability of the node ("active"|"pause"|"drain") (default "active")
      --cert-expiry duration                   Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
      --data-path-addr string                  Address or interface to use for data path traffic (format: <ip|interface>)
      --data-path-port uint32                  Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the
                                               default port (4789) is used.
      --default-addr-pool ipNetSlice           default address pool in CIDR format (default [])
      --default-addr-pool-mask-length uint32   default address pool subnet mask length (default 24)
      --dispatcher-heartbeat duration          Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
      --external-ca external-ca                Specifications of one or more certificate signing endpoints
      --force-new-cluster                      Force create a new cluster from current state
      --listen-addr node-addr                  Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
      --max-snapshots uint                     Number of additional Raft snapshots to retain
      --snapshot-interval uint                 Number of log entries between Raft snapshots (default 10000)
      --task-history-limit int                 Task history retention limit (default 5)

--advertise-addr:当前主机暴露的ip地址

--availability:当前节点状态(active、pause、drain),默认为active(可正常使用)

--listen-addr:监听地址,默认为0.0.0.0:2377

 

 

******************

docker swarm join

 

命令格式:docker swarm join [options]

[root@centos ~]# docker swarm join --help

Usage:	docker swarm join [OPTIONS] HOST:PORT

Join a swarm as a node and/or manager

Options:
      --advertise-addr string   Advertised address (format: <ip|interface>[:port])
      --availability string     Availability of the node ("active"|"pause"|"drain") (default "active")
      --data-path-addr string   Address or interface to use for data path traffic (format: <ip|interface>)
      --listen-addr node-addr   Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
      --token string            Token for entry into the swarm

--token:要加入集群的token

 

 

******************

docker swarm leave

 

命令格式:docker swarm leave [options]

[root@centos ~]# docker swarm leave --help

Usage:	docker swarm leave [OPTIONS]

Leave the swarm

Options:
  -f, --force   Force this node to leave the swarm, ignoring warnings

-f:强制离开集群

 

 

******************

docker swarm update

 

命令格式:docker swarm update [options]

[root@centos ~]# docker swarm update --help

Usage:	docker swarm update [OPTIONS]

Update the swarm

Options:
      --autolock                        Change manager autolocking setting (true|false)
      --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
      --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
      --external-ca external-ca         Specifications of one or more certificate signing endpoints
      --max-snapshots uint              Number of additional Raft snapshots to retain
      --snapshot-interval uint          Number of log entries between Raft snapshots (default 10000)
      --task-history-limit int          Task history retention limit (default 5)

--autolock:集群自动锁定设置

--cert-expiry:设置证书的有效期

--external-ca:设置自定义证书

--max-snapshots:最大保存的raft快照

--task-history-limit:历史任务保存数量,默认为5

--snapshot-interval:快照间隔周期

--dispatcher-heartbeat-duration:心跳检测周期,默认5s

 

 

**********************

service 命令:集群服务

 

命令格式:docker service command

[root@centos ~]# docker service --help

Usage:	docker service COMMAND

Manage services

Commands:
  create      Create a new service
  inspect     Display detailed information on one or more services
  logs        Fetch the logs of a service or task
  ls          List services
  ps          List the tasks of one or more services
  rm          Remove one or more services
  rollback    Revert changes to a service's configuration
  scale       Scale one or multiple replicated services
  update      Update a service

Run 'docker service COMMAND --help' for more information on a command.

create:创建服务

inspect:查看服务信息

logs:服务日志

ls:列出所有服务

ps:列出service的task

rm:删除服务

rollback:服务回滚

scale:服务伸缩

update:更新服务

 

 

******************

docker service create

 

命令格式:docker service create [options] image [command] [args]

Usage:	docker service create [OPTIONS] IMAGE [COMMAND] [ARG...]

Create a new service

Options:
      --config config                      Specify configurations to expose to the service
      --constraint list                    Placement constraints
      --container-label list               Container labels
      --credential-spec credential-spec    Credential spec for managed service account (Windows only)
  -d, --detach                             Exit immediately instead of waiting for the service to converge
      --dns list                           Set custom DNS servers
      --dns-option list                    Set DNS options
      --dns-search list                    Set custom DNS search domains
      --endpoint-mode string               Endpoint mode (vip or dnsrr) (default "vip")
      --entrypoint command                 Overwrite the default ENTRYPOINT of the image
  -e, --env list                           Set environment variables
      --env-file list                      Read in a file of environment variables
      --generic-resource list              User defined resources
      --group list                         Set one or more supplementary user groups for the container
      --health-cmd string                  Command to run to check health
      --health-interval duration           Time between running the check (ms|s|m|h)
      --health-retries int                 Consecutive failures needed to report unhealthy
      --health-start-period duration       Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)
      --health-timeout duration            Maximum time to allow one check to run (ms|s|m|h)
      --host list                          Set one or more custom host-to-IP mappings (host:ip)
      --hostname string                    Container hostname
      --init                               Use an init inside each service container to forward signals and reap processes
      --isolation string                   Service container isolation mode
  -l, --label list                         Service labels
      --limit-cpu decimal                  Limit CPUs
      --limit-memory bytes                 Limit Memory
      --log-driver string                  Logging driver for service
      --log-opt list                       Logging driver options
      --mode string                        Service mode (replicated or global) (default "replicated")
      --mount mount                        Attach a filesystem mount to the service
      --name string                        Service name
      --network network                    Network attachments
      --no-healthcheck                     Disable any container-specified HEALTHCHECK
      --no-resolve-image                   Do not query the registry to resolve image digest and supported platforms
      --placement-pref pref                Add a placement preference
  -p, --publish port                       Publish a port as a node port
  -q, --quiet                              Suppress progress output
      --read-only                          Mount the container's root filesystem as read only
      --replicas uint                      Number of tasks
      --replicas-max-per-node uint         Maximum number of tasks per node (default 0 = unlimited)
      --reserve-cpu decimal                Reserve CPUs
      --reserve-memory bytes               Reserve Memory
      --restart-condition string           Restart when condition is met ("none"|"on-failure"|"any") (default "any")
      --restart-delay duration             Delay between restart attempts (ns|us|ms|s|m|h) (default 5s)
      --restart-max-attempts uint          Maximum number of restarts before giving up
      --restart-window duration            Window used to evaluate the restart policy (ns|us|ms|s|m|h)
      --rollback-delay duration            Delay between task rollbacks (ns|us|ms|s|m|h) (default 0s)
      --rollback-failure-action string     Action on rollback failure ("pause"|"continue") (default "pause")
      --rollback-max-failure-ratio float   Failure rate to tolerate during a rollback (default 0)
      --rollback-monitor duration          Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h) (default 5s)
      --rollback-order string              Rollback order ("start-first"|"stop-first") (default "stop-first")
      --rollback-parallelism uint          Maximum number of tasks rolled back simultaneously (0 to roll back all at once) (default 1)
      --secret secret                      Specify secrets to expose to the service
      --stop-grace-period duration         Time to wait before force killing a container (ns|us|ms|s|m|h) (default 10s)
      --stop-signal string                 Signal to stop the container
      --sysctl list                        Sysctl options
  -t, --tty                                Allocate a pseudo-TTY
      --update-delay duration              Delay between updates (ns|us|ms|s|m|h) (default 0s)
      --update-failure-action string       Action on update failure ("pause"|"continue"|"rollback") (default "pause")
      --update-max-failure-ratio float     Failure rate to tolerate during an update (default 0)
      --update-monitor duration            Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 5s)
      --update-order string                Update order ("start-first"|"stop-first") (default "stop-first")
      --update-parallelism uint            Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
  -u, --user string                        Username or UID (format: <name|uid>[:<group|gid>])
      --with-registry-auth                 Send registry authentication details to swarm agents
  -w, --workdir string                     Working directory inside the container

--constraint:过滤条件

--mode:service 模式,replicated(默认)、global

--mount:数据卷

--name:服务名称

--replicas:副本数

-p、--publish port:暴露端口

--network:网络设置

 

 

******************

docker service update

 

命令格式:docker service update [options] service_name

Usage:	docker service update [OPTIONS] SERVICE

Update a service

Options:
      --args command                       Service command args
      --config-add config                  Add or update a config file on a service
      --config-rm list                     Remove a configuration file
      --constraint-add list                Add or update a placement constraint
      --constraint-rm list                 Remove a constraint
      --container-label-add list           Add or update a container label
      --container-label-rm list            Remove a container label by its key
      --credential-spec credential-spec    Credential spec for managed service account (Windows only)
  -d, --detach                             Exit immediately instead of waiting for the service to converge
      --dns-add list                       Add or update a custom DNS server
      --dns-option-add list                Add or update a DNS option
      --dns-option-rm list                 Remove a DNS option
      --dns-rm list                        Remove a custom DNS server
      --dns-search-add list                Add or update a custom DNS search domain
      --dns-search-rm list                 Remove a DNS search domain
      --endpoint-mode string               Endpoint mode (vip or dnsrr)
      --entrypoint command                 Overwrite the default ENTRYPOINT of the image
      --env-add list                       Add or update an environment variable
      --env-rm list                        Remove an environment variable
      --force                              Force update even if no changes require it
      --generic-resource-add list          Add a Generic resource
      --generic-resource-rm list           Remove a Generic resource
      --group-add list                     Add an additional supplementary user group to the container
      --group-rm list                      Remove a previously added supplementary user group from the container
      --health-cmd string                  Command to run to check health
      --health-interval duration           Time between running the check (ms|s|m|h)
      --health-retries int                 Consecutive failures needed to report unhealthy
      --health-start-period duration       Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)
      --health-timeout duration            Maximum time to allow one check to run (ms|s|m|h)
      --host-add list                      Add a custom host-to-IP mapping (host:ip)
      --host-rm list                       Remove a custom host-to-IP mapping (host:ip)
      --hostname string                    Container hostname
      --image string                       Service image tag
      --init                               Use an init inside each service container to forward signals and reap processes
      --isolation string                   Service container isolation mode
      --label-add list                     Add or update a service label
      --label-rm list                      Remove a label by its key
      --limit-cpu decimal                  Limit CPUs
      --limit-memory bytes                 Limit Memory
      --log-driver string                  Logging driver for service
      --log-opt list                       Logging driver options
      --mount-add mount                    Add or update a mount on a service
      --mount-rm list                      Remove a mount by its target path
      --network-add network                Add a network
      --network-rm list                    Remove a network
      --no-healthcheck                     Disable any container-specified HEALTHCHECK
      --no-resolve-image                   Do not query the registry to resolve image digest and supported platforms
      --placement-pref-add pref            Add a placement preference
      --placement-pref-rm pref             Remove a placement preference
      --publish-add port                   Add or update a published port
      --publish-rm port                    Remove a published port by its target port
  -q, --quiet                              Suppress progress output
      --read-only                          Mount the container's root filesystem as read only
      --replicas uint                      Number of tasks
      --replicas-max-per-node uint         Maximum number of tasks per node (default 0 = unlimited)
      --reserve-cpu decimal                Reserve CPUs
      --reserve-memory bytes               Reserve Memory
      --restart-condition string           Restart when condition is met ("none"|"on-failure"|"any")
      --restart-delay duration             Delay between restart attempts (ns|us|ms|s|m|h)
      --restart-max-attempts uint          Maximum number of restarts before giving up
      --restart-window duration            Window used to evaluate the restart policy (ns|us|ms|s|m|h)
      --rollback                           Rollback to previous specification
      --rollback-delay duration            Delay between task rollbacks (ns|us|ms|s|m|h)
      --rollback-failure-action string     Action on rollback failure ("pause"|"continue")
      --rollback-max-failure-ratio float   Failure rate to tolerate during a rollback
      --rollback-monitor duration          Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h)
      --rollback-order string              Rollback order ("start-first"|"stop-first")
      --rollback-parallelism uint          Maximum number of tasks rolled back simultaneously (0 to roll back all at once)
      --secret-add secret                  Add or update a secret on a service
      --secret-rm list                     Remove a secret
      --stop-grace-period duration         Time to wait before force killing a container (ns|us|ms|s|m|h)
      --stop-signal string                 Signal to stop the container
      --sysctl-add list                    Add or update a Sysctl option
      --sysctl-rm list                     Remove a Sysctl option
  -t, --tty                                Allocate a pseudo-TTY
      --update-delay duration              Delay between updates (ns|us|ms|s|m|h)
      --update-failure-action string       Action on update failure ("pause"|"continue"|"rollback")
      --update-max-failure-ratio float     Failure rate to tolerate during an update
      --update-monitor duration            Duration after each task update to monitor for failure (ns|us|ms|s|m|h)
      --update-order string                Update order ("start-first"|"stop-first")
      --update-parallelism uint            Maximum number of tasks updated simultaneously (0 to update all at once)
  -u, --user string                        Username or UID (format: <name|uid>[:<group|gid>])
      --with-registry-auth                 Send registry authentication details to swarm agents
  -w, --workdir string                     Working directory inside the container

--mount-add、--mount-rm:添加、删除数据卷

--publish-add、--publish-rm:添加、删除端口

--network-add、--network-rm:添加、删除网络

--rollback:服务回滚到之前的版本

 

 

**********************

node 命令:集群节点

 

docker node command [options]

Usage:	docker node COMMAND

Manage Swarm nodes

Commands:
  demote      Demote one or more nodes from manager in the swarm
  inspect     Display detailed information on one or more nodes
  ls          List nodes in the swarm
  promote     Promote one or more nodes to manager in the swarm
  ps          List tasks running on one or more nodes, defaults to current node
  rm          Remove one or more nodes from the swarm
  update      Update a node

Run 'docker node COMMAND --help' for more information on a command.

promote:worker node升级为manager node

demote:manager node降级为worker node

ls:列出集群中的节点

ps:列出节点上的task

rm:从集群中删除节点

update:更新节点

 

 

******************

docker node update

 

命令格式:docker node update [options] node_name

Usage:	docker node update [OPTIONS] NODE

Update a node

Options:
      --availability string   Availability of the node ("active"|"pause"|"drain")
      --label-add list        Add or update a node label (key=value)
      --label-rm list         Remove a node label if exists
      --role string           Role of the node ("worker"|"manager")

--availability:更新节点可用性

--label-add:添加节点标签

--label-rm:删除节点标签

--role:更新节点角色,manager、worker

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

docker swarm 使用说明 的相关文章

随机推荐

  • 音视频基础之音频编码原理简介

    一 xff1a 隐蔽信号 数字音频信号如果不加压缩地直接进行传送 xff0c 将会占用极大的带宽 例如 xff0c 一套双声道数字音频若取样频率为44 1KHz xff0c 每样值按16bit量化 xff0c 则其码率为 xff1a 244
  • three.js+vue浏览器端展示nrrd+vtk3D模型(截图功能+颜色功能)

    前言 前面做了vue 43 three js展示nrrd 43 vtk3D模型 vue框架集成后 xff0c 想给我们的项目加一些功能 xff0c 因为目前考虑的只是展示 xff0c 没有需求 xff0c 所以做一些功能尝试添加 xff0c
  • 通过apt方式安装opencv

    转自 xff1a https www cnblogs com cxchanpin p 7103012 html 本文介绍怎样在树莓派中通过apt方式安装opencv xff0c 并通过一个简单的样例说明怎样使用opencv 相比于源码方式安
  • PHP7使用MongoDB\Driver\Manager类实现增删改查

    这篇笔记记录了PHP7使用官方扩展MongoDB Driver提供的Manager BulkWrite Query Cursor WriteResult类实现增删改查的过程 相关笔记 xff1a CentOS6 9安装mongodb和php
  • 牛妹爱数列_牛客练习赛67

    题目链接 xff1a https ac nowcoder com acm contest 6885 D 题意 给你一个长度为n的仅包含01的序列a xff0c 并执行以下操作单点修改 xff1a 0 gt 1 xff0c 1 gt 0前缀修
  • C++11 thread类在windows上无法使用。std 没有成员 thread、thread not member of std

    C 43 43 11 thread类在windows上无法使用 std 没有成员 thread thread not member of std 解决方法 使用C 43 43 11其他特性完全没问题 这个问题原因是MinGW GCC当前仍缺
  • nginx编译安装常见报错

    编译nginx root 64 iZgt88z6l1kvd7Z nginx 1 10 1 configure prefix 61 usr local nginx with http ssl module with pcre 61 pcre
  • 【万人千题】C语言矩阵的转置12.4总结

    目录 一 xff1a 知识点 1 xff0c 概念 二 xff1a 应用 1 xff0c 另开一个数组来存放转置内容 xff08 row和col不等的情况 xff09 2 xff0c n阶矩阵 xff08 row与col相等的情况 xff0
  • MarkDown--- 让CSDN的博客更炫丽,添加小图标,调整字体大小和颜色

    MarkDown 让CSDN的博客更炫丽 xff0c 添加小图标 xff0c 调整字体大小和颜色 1 Icon2 Font3 Color4 Gif1 Animal2 ColorBall3 cartoon4 Beautiful5 JumpSh
  • 手把手教你linux如何挂载磁盘,进行扩容

    Linux挂载磁盘 xff0c 进行扩容 1 检查新磁盘并设定1 1 检查新磁盘1 2 建立PV1 3 建立VG1 4 建立LV 2 挂载2 1 挂载到新目录2 2 挂载到根目录 3 移除3 1 移除挂载关系3 2 Remove VG3 3
  • VMware安装Win11+WSA子系统和使用教程

    VMware安装Win11 43 WSA子系统和使用教程 作者 xff1a Sna1lGo 时间 xff1a 2022 9 29 下载相关文件 xff1a Win11镜像 xff1a Download Windows 11 microsof
  • 计算机网络_以太网帧中的前导码和帧间隙

    以太网帧长中的前导码和帧间隙 1 概述 目前出现三个bug都涉及到L1和L2限速不准确的问题 xff1a 在计算网络带宽时 xff0c 报文设置的越小 xff0c 差距就越大 这个问题几乎所有新手都会遇到 xff0c 在此梳理一下 xff0
  • 初识Nginx和环境准备

    初识Nginx和环境准备 Nginx的优点Nginx的环境搭建开始搭建Nginx环境 Nginx的优点 支持海量的高并发 xff1a 采用IO多路复用epoll 官方测试Nginx能够支持5万并发链接 xff0c 实际生产环境中可以支撑2
  • vim的vimrc配置

    windows 34 modified by Neoh set helplang 61 cn 34 使用中文帮助文档 set encoding 61 utf 8 34 查看utf 8格式的帮助文档 set fileencodings 61
  • C++线程同步——阻塞线程的方法

    一般 xff0c 使线程阻塞我们可以使用 while condition for condition 等循环条件使之线程内语句执行在循环处无法向下继续执行 xff0c 但这样并不是真正意义上的线程阻塞 xff0c 当前线程仍然在执行 xff
  • 利用爬虫爬取游戏网站图片和信息并生成词云图

    一 项目简介 1 1 本项目博客地址 xff1a 1 2 项目完成的功能与特色 功能 xff1a 爬取目标游戏网站的皮肤图片及信息并用爬取的信息生成词云图 特色 xff1a 将爬取的信息做简单的处理 xff0c 并将爬取的图片直接保存在文件
  • Debian搭建FTP服务器及Caddy网站并上传

    Debian搭建FTP服务器及Caddy网站并上传 安装配置FTP1 安装2 查看网络服务状态3 配置vsftpd 安装配置Caddy1 安装Caddy2 配置Caddy 上传网站到服务器疑难解决 参考 安装配置FTP 首先用SSH方式连接
  • linux 软件安装

    linux 软件安装 yum xff1a 软件包管理工具 命令格式 xff1a yum options command command 列表 List of Commands check 检查 RPM 数据库问题 check update
  • POJ2823 滑动窗口 (单调队列)

    题目 来学习一下单调队列 xff1a 他只可以从队尾入队 xff0c 但可以从队尾或队首出队 xff0c 来维护队列的单调性 单调队列有两种单调性 xff1a 元素的值单调和元素的下标单调 单调队列可以用来优化DP 状态转移方程形如dp i
  • docker swarm 使用说明

    docker swarm 使用说明 swarm 命令 xff1a 管理集群 docker swarm command root 64 centos docker swarm help Usage docker swarm COMMAND M