目录搜索
ComposeAbout versions and upgrading (Compose)ASP.NET Core + SQL Server on Linux (Compose)CLI environment variables (Compose)Command-line completion (Compose)Compose(组成)Compose command-line reference(组合命令行参考)Control startup order (Compose)Django and PostgreSQL (Compose)Docker stacks and distributed application bundles (Compose)docker-compose build(docker-compose构建)docker-compose bundledocker-compose configdocker-compose createdocker-compose downdocker-compose eventsdocker-compose execdocker-compose helpdocker-compose imagesdocker-compose killdocker-compose logsdocker-compose pausedocker-compose portdocker-compose psdocker-compose pulldocker-compose pushdocker-compose restartdocker-compose rmdocker-compose rundocker-compose scaledocker-compose startdocker-compose stopdocker-compose topdocker-compose unpausedocker-compose upEnvironment file (Compose)Environment variables in ComposeExtend services in ComposeFrequently asked questions (Compose)Getting started (Compose)Install ComposeLink environment variables (deprecated) (Compose)Networking in ComposeOverview of Docker ComposeOverview of docker-compose CLIQuickstart: Compose and WordPressRails and PostgreSQL (Compose)Sample apps with ComposeUsing Compose in productionUsing Compose with SwarmEngine.NET Core application (Engine)About images, containers, and storage drivers (Engine)Add nodes to the swarm (Engine)Apply custom metadata (Engine)Apply rolling updates (Engine)apt-cacher-ngBest practices for writing Dockerfiles (Engine)Binaries (Engine)Bind container ports to the host (Engine)Breaking changes (Engine)Build your own bridge (Engine)Configure container DNS (Engine)Configure container DNS in user-defined networks (Engine)CouchDB (Engine)Create a base image (Engine)Create a swarm (Engine)Customize the docker0 bridge (Engine)Debian (Engine)Default bridge networkDelete the service (Engine)Deploy a service (Engine)Deploy services to a swarm (Engine)Deprecated Engine featuresDocker container networking (Engine)Docker overview (Engine)Docker run reference (Engine)Dockerfile reference (Engine)Dockerize an applicationDrain a node (Engine)EngineFAQ (Engine)Fedora (Engine)Get started (Engine)Get started with macvlan network driver (Engine)Get started with multi-host networking (Engine)How nodes work (Engine)How services work (Engine)Image management (Engine)Inspect the service (Engine)Install Docker (Engine)IPv6 with Docker (Engine)Join nodes to a swarm (Engine)Legacy container links (Engine)Lock your swarm (Engine)Manage nodes in a swarm (Engine)Manage sensitive data with Docker secrets (Engine)Manage swarm security with PKI (Engine)Manage swarm service networks (Engine)Migrate to Engine 1.10Optional Linux post-installation steps (Engine)Overview (Engine)PostgreSQL (Engine)Raft consensus in swarm mode (Engine)Riak (Engine)Run Docker Engine in swarm modeScale the service (Engine)SDKs (Engine)Select a storage driver (Engine)Set up for the tutorial (Engine)SSHd (Engine)Storage driver overview (Engine)Store service configuration data (Engine)Swarm administration guide (Engine)Swarm mode key concepts (Engine)Swarm mode overlay network security model (Engine)Swarm mode overview (Engine)Understand container communication (Engine)Use multi-stage builds (Engine)Use swarm mode routing mesh (Engine)Use the AUFS storage driver (Engine)Use the Btrfs storage driver (Engine)Use the Device mapper storage driver (Engine)Use the OverlayFS storage driver (Engine)Use the VFS storage driver (Engine)Use the ZFS storage driver (Engine)Engine: Admin GuideAmazon CloudWatch logs logging driver (Engine)Bind mounts (Engine)Collect Docker metrics with Prometheus (Engine)Configuring and running Docker (Engine)Configuring logging drivers (Engine)Control and configure Docker with systemd (Engine)ETW logging driver (Engine)Fluentd logging driver (Engine)Format command and log output (Engine)Google Cloud logging driver (Engine)Graylog Extended Format (GELF) logging driver (Engine)Journald logging driver (Engine)JSON File logging driver (Engine)Keep containers alive during daemon downtime (Engine)Limit a container's resources (Engine)Link via an ambassador container (Engine)Log tags for logging driver (Engine)Logentries logging driver (Engine)PowerShell DSC usage (Engine)Prune unused Docker objects (Engine)Run multiple services in a container (Engine)Runtime metrics (Engine)Splunk logging driver (Engine)Start containers automatically (Engine)Storage overview (Engine)Syslog logging driver (Engine)tmpfs mountsTroubleshoot volume problems (Engine)Use a logging driver plugin (Engine)Using Ansible (Engine)Using Chef (Engine)Using Puppet (Engine)View a container's logs (Engine)Volumes (Engine)Engine: CLIDaemon CLI reference (dockerd) (Engine)dockerdocker attachdocker builddocker checkpointdocker checkpoint createdocker checkpoint lsdocker checkpoint rmdocker commitdocker configdocker config createdocker config inspectdocker config lsdocker config rmdocker containerdocker container attachdocker container commitdocker container cpdocker container createdocker container diffdocker container execdocker container exportdocker container inspectdocker container killdocker container logsdocker container lsdocker container pausedocker container portdocker container prunedocker container renamedocker container restartdocker container rmdocker container rundocker container startdocker container statsdocker container stopdocker container topdocker container unpausedocker container updatedocker container waitdocker cpdocker createdocker deploydocker diffdocker eventsdocker execdocker exportdocker historydocker imagedocker image builddocker image historydocker image importdocker image inspectdocker image loaddocker image lsdocker image prunedocker image pulldocker image pushdocker image rmdocker image savedocker image tagdocker imagesdocker importdocker infodocker inspectdocker killdocker loaddocker logindocker logoutdocker logsdocker networkdocker network connectdocker network createdocker network disconnectdocker network inspectdocker network lsdocker network prunedocker network rmdocker nodedocker node demotedocker node inspectdocker node lsdocker node promotedocker node psdocker node rmdocker node updatedocker pausedocker plugindocker plugin createdocker plugin disabledocker plugin enabledocker plugin inspectdocker plugin installdocker plugin lsdocker plugin pushdocker plugin rmdocker plugin setdocker plugin upgradedocker portdocker psdocker pulldocker pushdocker renamedocker restartdocker rmdocker rmidocker rundocker savedocker searchdocker secretdocker secret createdocker secret inspectdocker secret lsdocker secret rmdocker servicedocker service createdocker service inspectdocker service logsdocker service lsdocker service psdocker service rmdocker service scaledocker service updatedocker stackdocker stack deploydocker stack lsdocker stack psdocker stack rmdocker stack servicesdocker startdocker statsdocker stopdocker swarmdocker swarm cadocker swarm initdocker swarm joindocker swarm join-tokendocker swarm leavedocker swarm unlockdocker swarm unlock-keydocker swarm updatedocker systemdocker system dfdocker system eventsdocker system infodocker system prunedocker tagdocker topdocker unpausedocker updatedocker versiondocker volumedocker volume createdocker volume inspectdocker volume lsdocker volume prunedocker volume rmdocker waitUse the Docker command line (Engine)Engine: ExtendAccess authorization plugin (Engine)Docker log driver pluginsDocker network driver plugins (Engine)Extending Engine with pluginsManaged plugin system (Engine)Plugin configuration (Engine)Plugins API (Engine)Volume plugins (Engine)Engine: SecurityAppArmor security profiles for Docker (Engine)Automation with content trust (Engine)Content trust in Docker (Engine)Delegations for content trust (Engine)Deploying Notary (Engine)Docker security (Engine)Docker security non-events (Engine)Isolate containers with a user namespace (Engine)Manage keys for content trust (Engine)Play in a content trust sandbox (Engine)Protect the Docker daemon socket (Engine)Seccomp security profiles for Docker (Engine)Secure EngineUse trusted imagesUsing certificates for repository client verification (Engine)Engine: TutorialsEngine tutorialsNetwork containers (Engine)Get StartedPart 1: OrientationPart 2: ContainersPart 3: ServicesPart 4: SwarmsPart 5: StacksPart 6: Deploy your appMachineAmazon Web Services (Machine)Digital Ocean (Machine)docker-machine activedocker-machine configdocker-machine createdocker-machine envdocker-machine helpdocker-machine inspectdocker-machine ipdocker-machine killdocker-machine lsdocker-machine provisiondocker-machine regenerate-certsdocker-machine restartdocker-machine rmdocker-machine scpdocker-machine sshdocker-machine startdocker-machine statusdocker-machine stopdocker-machine upgradedocker-machine urlDriver options and operating system defaults (Machine)Drivers overview (Machine)Exoscale (Machine)Generic (Machine)Get started with a local VM (Machine)Google Compute Engine (Machine)IBM Softlayer (Machine)Install MachineMachineMachine CLI overviewMachine command-line completionMachine concepts and helpMachine overviewMicrosoft Azure (Machine)Microsoft Hyper-V (Machine)Migrate from Boot2Docker to MachineOpenStack (Machine)Oracle VirtualBox (Machine)Provision AWS EC2 instances (Machine)Provision Digital Ocean Droplets (Machine)Provision hosts in the cloud (Machine)Rackspace (Machine)VMware Fusion (Machine)VMware vCloud Air (Machine)VMware vSphere (Machine)NotaryClient configuration (Notary)Common Server and signer configurations (Notary)Getting started with NotaryNotary changelogNotary configuration filesRunning a Notary serviceServer configuration (Notary)Signer configuration (Notary)Understand the service architecture (Notary)Use the Notary client
文字

描述

更新服务

使用

docker service update [OPTIONS] SERVICE

备选方案

名字,简写

默认

描述

--args


服务命令参数

--config-add


添加或更新服务上的配置文件

--config-RM


删除配置文件

--constraint-add


添加或更新展示位置约束

--constraint-RM


删除约束

--container-label-add


添加或更新容器标签

--container-label-rm


用钥匙取出容器标签

--credential-spec


托管服务帐户的凭证规范(仅限Windows)

--detach,-d

立即退出,而不是等待服务收敛

--dns-add


添加或更新自定义DNS服务器

--dns-option-add


添加或更新DNS选项

--dns-option-rm


删除一个DNS选项

--dns-rm


删除自定义的DNS服务器

--dns-search-add


添加或更新自定义DNS搜索域

--dns-search-rm


删除一个DNS搜索域

--endpoint-mode


端点模式(vip或dnsrr)

--entrypoint


覆盖图像的默认入口点

--env-add


添加或更新环境变量

--env-RM


删除一个环境变量

--force

即使没有更改需要,也强制更新

--group-add


向容器添加一个附加的补充用户组

--group-RM


从容器中删除先前添加的补充用户组

--health-cmd


运行以检查运行状况的命令

--health-interval


运行检查之间的时间(ms | s | m | h)

--health-retries

0

需要报告不健康的连续失败

--health-retries


在重新计数到不稳定(ms | s | m | h)之前,容器初始化的开始时间段

--health-timeout


允许一次检查运行的最长时间(ms | s | m | h)

--host加


添加或更新自定义主机到IP映射(主机:IP)

--host-RM


删除自定义的主机到IP映射(主机:IP)

--hostname


容器主机名

--image


服务图片标签

--label-add


添加或更新服务标签

--label-RM


用钥匙去除标签

--limit-CPU


限制CPU

--limit-memory

0

限制记忆

--log-driver


记录驱动程序的服务

--log-OPT


记录驱动程序选项

--mount-add


添加或更新服务上的装载

--mount-RM


通过目标路径移除一个安装

--network加


添加一个网络

--network-RM


删除网络

--no-healthcheck

禁用任何容器指定的HEALTHCHECK

--no-resolve-image

不要查询注册表来解析图像摘要和支持的平台

--placement-PREF-ADD


添加展示位置首选项

--placement-PREF-RM


删除展示位置偏好设置

--publish相加


添加或更新已发布的端口

--publish-RM


通过目标端口删除发布的端口

--quiet,-q

抑制进度输出

--read-only

将容器的根文件系统挂载为只读

--replicas


任务数量

--reserve-CPU


预留CPU

--reserve-memory

0

保留内存

--restart-condition


条件满足时重新启动(“none”|“on-failure”|“any”)

--restart-delay


重启尝试之间的延迟(ns | us | ms | s | m | h)

--restart-max-attempts


放弃前的最大重启次数

--restart-window


用于评估重新启动策略的窗口(ns | us | ms | s | m | h)

--rollback

回退到先前的规范

--rollback-delay

0

任务回滚之间的延迟(ns | us | ms | s | m | h)

--rollback-failure-action


回滚失败的操作(“暂停”|“继续”)

--rollback-max-failure-ratio

0

在回滚期间容忍的失败率

--rollback-monitor

0

每个任务回滚后监视失败的持续时间(ns | us | ms | s | m | h)

--rollback-order


回滚顺序(“start-first”|“stop-first”)

--rollback-parallelism

0

同时回滚的任务的最大数量(0一次全部回滚)

--secret-add


添加或更新服务的秘密

--secret-RM


去掉一个秘密

--stop-grace-period


强制杀死一个容器之前的等待时间(ns | us | ms | s | m | h)

--stop-signal


停止容器的信号

--tty, -t

分配一个伪TTY

--update-delay

0

更新之间的延迟(ns | us | ms | s | m | h)

--update-failure-action


更新失败的操作(“暂停”|“继续”|“回滚”)

--update-max-failure-ratio

0

更新期间容错的失败率

--update-monitor

0

(ns | us | ms | s | m | h)每个任务更新后的持续时间

--update-order


更新顺序(“start-first”|“stop-first”)

--update-parallelism

0

同时更新的最大任务数(0个一次全部更新)

--user,-u


用户名或UID(格式:<名称| uid>:<组| gid>)

--with-registry-auth

向注册代理发送注册表认证详细信息

--workdir,-w


容器内的工作目录

父命令

命令

描述

docker 服务

管理服务

相关命令

命令

描述

docker  服务创建

创建一项新服务

docker  服务检查

显示一项或多项服务的详细信息

docker  服务日志

获取服务或任务的日志

docker  服务ls

列出服务

docker  服务ps

列出一项或多项服务的任务

docker  服务rm

删除一项或多项服务

docker  服务规模

扩展一个或多个复制服务

docker  服务更新

更新服务

扩展描述

按照指定的参数描述更新服务。该命令必须以管理器节点为目标运行。参数与docker service create。相同。请参阅描述以获取更多信息。

通常,更新服务只会导致服务的任务被替换为新服务,如果对服务的更改需要重新创建任务才能生效。例如,只有更改--update-parallelism设置才会重新创建任务,因为单个任务不受此设置的影响。但是,--force标志将导致任务被重新创建。这可以用来执行滚动重启,而不会对服务参数进行任何更改。

实例

更新服务

$ docker service update --limit-cpu 2 redis

执行滚动重新启动,不更改参数。

$ docker service update --force --update-parallelism 1 --update-delay 30s redis

在这个例子中,--force标志导致服务的任务被关闭并被新的替换,即使其他参数通常都不会导致这种情况发生。--update-parallelism 1设置确保一次只替换一个任务(这是默认行为)。--update-delay 30s设置在任务之间引入了30秒的延迟,以便滚动重启逐渐发生。

添加或移除挂载

使用--mount-add--mount-rm选项添加或删除服务的绑定挂载或volume。

以下示例创建一个将test-datavolume挂载到的服务/somewhere。下一步更新服务以将other-volumevolume挂接到/somewhere-elsevolume,最后一步卸载/somewhere挂载点,从而有效地移除test-datavolume。每个命令都会返回服务名称。

  • --mount-add标志采用了相同的参数--mount上的标志service create。有关详细信息,请参阅参考中的volume和绑定挂载部分service create

  • --mount-rm标志采用target安装路径。

$ docker service create \    --name=myservice \    --mount \
      type=volume,source=test-data,target=/somewhere \
    nginx:alpine \
    myservice

myservice

$ docker service update \    --mount-add \
      type=volume,source=other-volume,target=/somewhere-else \
    myservice

myservice

$ docker service update --mount-rm /somewhere myservice

myservice

恢复到服务的以前版本。

使用--rollback选项恢复到服务的前一个版本。

这将使服务恢复到最近一次配置之前的配置。docker service update命令。

下面的示例将服务的副本数量从4更新到5,然后回滚到以前的配置。

$ docker service update --replicas=5 web

web

$ docker service ls

ID            NAME  MODE        REPLICAS  IMAGE
80bvrzp6vxf3  web   replicated  0/5       nginx:alpine

回滚web服务...

$ docker service update --rollback web

web

$ docker service ls

ID            NAME  MODE        REPLICAS  IMAGE
80bvrzp6vxf3  web   replicated  0/4       nginx:alpine

其他选项也可以结合使用--rollback,例如,--update-delay 0s执行任务之间没有延迟的回滚:

$ docker service update \  --rollback \  --update-delay 0s
  web

web

服务也可以设置为在更新失败时自动回滚到以前的版本。要设置自动回滚服务,请使用--update-failure-action=rollback。如果成功更新失败的部分任务超过了给定的值,将会触发回滚--update-max-failure-ratio

恢复操作的速率,并行性和其他参数由通过以下标志传递的值确定:

  • --rollback-delay

  • --rollback-failure-action

  • --rollback-max-failure-ratio

  • --rollback-monitor

  • --rollback-parallelism

例如,设置的服务--update-parallelism 1 --rollback-parallelism 3将在正常更新期间一次更新一个任务,但在回滚期间,一次会执行3个任务。这些回滚参数在自动回滚和使用手动启动--rollback的回滚期间都被重视。

添加或删除秘密

使用--secret-add--secret-rm选项添加或删除服务的机密。

以下示例添加一个名为ssh-2并删除的秘密ssh-1

$ docker service update \    --secret-add source=ssh-2,target=ssh-2 \    --secret-rm ssh-1 \
    myservice

使用模板更新服务

service update支持使用模板的一些标志。请参阅service create参考。

上一篇:下一篇: