1. docker deploy
1.1. 描述
部署新服务或更新现有服务。
只有在 Docker Daemon 开启 experimental features 实验性功能时才有效。
1.2. 帮助
$ docker deploy --help
Usage: docker deploy [OPTIONS] STACK
Deploy a new stack or update an existing stack
Options:
--bundle-file string Path to a Distributed Application Bundle file
-c, --compose-file strings Path to a Compose file, or "-" to read from stdin
--namespace string Kubernetes namespace to use
--prune Prune services that are no longer referenced
--resolve-image string Query the registry to resolve image digest and supported platforms
("always"|"changed"|"never") (default "always")
--with-registry-auth Send registry authentication details to Swarm agents
1.3. 选项
选项,简写 | 默认值 | 描述 | |
---|---|---|---|
--bundle-file | - | Swarm 集群专用。分布式应用程序捆绑文件的路径 | |
--compose-file, -c | - | compose 文件的路径,也可以 - 标准输入 STDIN |
|
--namespace | - | kubernetes 集群专用。kubernetes 集群中 namespace 的名称 | |
--prune | false | Swarm 集群专用。清理不再被引用的服务 | |
--resolve-image | always | Swarm 集群专用。查询镜像仓库 registry,确定 digest 摘要和支持的平台(可选“always/changed/never”) | |
--with-registry-auth | false | Swarm 集群专用。想 Swarm Agent 发送详细的认证信息 |
1.4. 示例
- 使用docker-compose文件进行部署,支持compose在3.0及以上版本
$ docker stack deploy --compose-file docker-compose.yml vossibility
Ignoring unsupported options: links
Creating network vossibility_vossibility
Creating network vossibility_default
Creating service vossibility_nsqd
Creating service vossibility_logstash
Creating service vossibility_elasticsearch
Creating service vossibility_kibana
Creating service vossibility_ghollector
Creating service vossibility_lookupd
验证服务是否已经存在
$ docker service ls
ID NAME MODE REPLICAS IMAGE
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
4tjx9biia6fs vossibility_elasticsearch replicated 1/1 elasticsearch@sha256:12ac7c6af55d001f71800b83ba91a04f716e58d82e748fa6e5a7359eed2301aa
7563uuzr9eys vossibility_kibana replicated 1/1 kibana@sha256:6995a2d25709a62694a937b8a529ff36da92ebee74bafd7bf00e6caf6db2eb03
9gc5m4met4he vossibility_logstash replicated 1/1 logstash@sha256:2dc8bddd1bb4a5a34e8ebaf73749f6413c101b2edef6617f2f7713926d2141fe
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
- 使用DAB文件部署
$ docker stack deploy --bundle-file vossibility-stack.dab vossibility
Loading bundle from vossibility-stack.dab
Creating service vossibility_elasticsearch
Creating service vossibility_kibana
Creating service vossibility_logstash
Creating service vossibility_lookupd
Creating service vossibility_nsqd
Creating service vossibility_vossibility-collector
查看服务是否已经创建
$ docker service ls
ID NAME MODE REPLICAS IMAGE
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
4tjx9biia6fs vossibility_elasticsearch replicated 1/1 elasticsearch@sha256:12ac7c6af55d001f71800b83ba91a04f716e58d82e748fa6e5a7359eed2301aa
7563uuzr9eys vossibility_kibana replicated 1/1 kibana@sha256:6995a2d25709a62694a937b8a529ff36da92ebee74bafd7bf00e6caf6db2eb03
9gc5m4met4he vossibility_logstash replicated 1/1 logstash@sha256:2dc8bddd1bb4a5a34e8ebaf73749f6413c101b2edef6617f2f7713926d2141fe
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
1.5. 参考
https://docs.docker.com/v18.09/engine/reference/commandline/deploy/ https://www.php.cn/manual/view/36037.html