- 浏览: 2493593 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker Swarm 2020(1)Simply Install and Use Swarm
Check my Docker
> docker --version
Docker version 19.03.8, build afacb8b
Swarm Manager - rancher-home
Swarm Worker - rancher-worker1
Swarm Worker - rancher-worker2
Some useful ports:
2377 - cluster management
7946 - node to node
4789 - overlay network
On rancher-home
> docker swarm init --advertise-addr 192.168.56.110
Swarm initialized: current node (st1b4xuylrj6mm5oggsk6hp04) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
If I forget about the token information just in case
> docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
> docker info
Swarm: active
NodeID: st1b4xuylrj6mm5oggsk6hp04
Is Manager: true
ClusterID: linol1nuatvwjbvquh1fg7x8h
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
Add the worker node to the swarm cluster
On rancher-worker1
> docker --version
Docker version 19.03.8, build afacb8b
Join the cluster
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On rancher-worker2
> docker --version
Docker version 19.03.8, build afacb8b
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On the manager machine, we can see all the nodes
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Ready Active 19.03.8
Remove the node from cluster
> docker swarm leave
Node left the swarm.
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Down Active 19.03.8
Remove it from the manager
> docker node rm --force ccr3520glvgpyg7dn1zbkr8zg
ccr3520glvgpyg7dn1zbkr8zg
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
Manager and Deploy Service
Create a simple service
> docker service create --replicas 1 --name helloworld alpine ping docker.com
m45as37skje2gts6t6curew77
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
List the service
> docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m45as37skje2 helloworld replicated 1/1 alpine:latest
Check the detail
> docker service inspect --pretty helloworld
ID: m45as37skje2gts6t6curew77
Name: helloworld
Service Mode: Replicated
Replicas: 1
Placement:
UpdateConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Update order: stop-first
List the server information
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vo5d6agsy1dw helloworld.1 alpine:latest rancher-home Running Running about a minute ago
Scale the service to 5
> docker service scale helloworld=5
List all the services
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
30nlrg5uu4c8 helloworld.1 alpine:latest rancher-home Running Running 3 minutes ago
vo5d6agsy1dw \_ helloworld.1 alpine:latest rancher-home Shutdown Failed 3 minutes ago "task: non-zero exit (255)"
fa9e3qlmcm47 helloworld.2 alpine:latest rancher-worker2 Running Running 30 seconds ago
8mr4dyaga779 helloworld.3 alpine:latest rancher-worker1 Running Running 29 seconds ago
7hbk7w99fo8z helloworld.4 alpine:latest rancher-worker1 Running Running 29 seconds ago
0s7rbd9vwv3r helloworld.5 alpine:latest rancher-home Running Running 35 seconds ago
Remove the service
> docker service rm helloworld
Run and Update the Tomcat Service
> docker service create --replicas 1 --name tomcat-service tomcat:8.5.8
Scale up to 2
> docker service scale tomcat-service=2
Rolling update to tomcat:9.0.33
> docker service update --image tomcat:9.0.33 tomcat-service
Check status
> service ps tomcat-service
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tei2ojnu7jxk tomcat-service.1 tomcat:9.0.33 rancher-worker2 Running Running 33 seconds ago
p6fg4k7l2jie \_ tomcat-service.1 tomcat:8.5.8 rancher-worker2 Shutdown Shutdown 53 seconds ago
q2it5kmfvois tomcat-service.2 tomcat:9.0.33 rancher-home Running Running 55 seconds ago
e3dnf70mx0km \_ tomcat-service.2 tomcat:8.5.8 rancher-home Shutdown Shutdown about a minute ago
r5kvdoruqdcf tomcat-service.3 tomcat:9.0.33 rancher-worker1 Running Running about a minute ago
33j1j47rk4pn \_ tomcat-service.3 tomcat:8.5.8 rancher-worker1 Shutdown Shutdown about a minute ago
Only see 3 history
> docker swarm update --task-history-limit 3
References:
https://yq.aliyun.com/articles/225511
https://outmanzzq.github.io/2019/06/14/portainer-for-docker-swarm/
https://note.qidong.name/2018/11/docker-swarm/
https://www.jianshu.com/p/df744c4e375e
https://github.com/jasonGeng88/blog/blob/master/201704/docker_swarm.md
https://stackoverflow.com/questions/41705134/how-can-i-remove-shutdown-docker-service-tasks-after-a-rolling-update
Maybe an useful tool
https://github.com/docker/machine
Check my Docker
> docker --version
Docker version 19.03.8, build afacb8b
Swarm Manager - rancher-home
Swarm Worker - rancher-worker1
Swarm Worker - rancher-worker2
Some useful ports:
2377 - cluster management
7946 - node to node
4789 - overlay network
On rancher-home
> docker swarm init --advertise-addr 192.168.56.110
Swarm initialized: current node (st1b4xuylrj6mm5oggsk6hp04) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
If I forget about the token information just in case
> docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
> docker info
Swarm: active
NodeID: st1b4xuylrj6mm5oggsk6hp04
Is Manager: true
ClusterID: linol1nuatvwjbvquh1fg7x8h
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
Add the worker node to the swarm cluster
On rancher-worker1
> docker --version
Docker version 19.03.8, build afacb8b
Join the cluster
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On rancher-worker2
> docker --version
Docker version 19.03.8, build afacb8b
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On the manager machine, we can see all the nodes
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Ready Active 19.03.8
Remove the node from cluster
> docker swarm leave
Node left the swarm.
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Down Active 19.03.8
Remove it from the manager
> docker node rm --force ccr3520glvgpyg7dn1zbkr8zg
ccr3520glvgpyg7dn1zbkr8zg
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
Manager and Deploy Service
Create a simple service
> docker service create --replicas 1 --name helloworld alpine ping docker.com
m45as37skje2gts6t6curew77
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
List the service
> docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m45as37skje2 helloworld replicated 1/1 alpine:latest
Check the detail
> docker service inspect --pretty helloworld
ID: m45as37skje2gts6t6curew77
Name: helloworld
Service Mode: Replicated
Replicas: 1
Placement:
UpdateConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Update order: stop-first
List the server information
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vo5d6agsy1dw helloworld.1 alpine:latest rancher-home Running Running about a minute ago
Scale the service to 5
> docker service scale helloworld=5
List all the services
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
30nlrg5uu4c8 helloworld.1 alpine:latest rancher-home Running Running 3 minutes ago
vo5d6agsy1dw \_ helloworld.1 alpine:latest rancher-home Shutdown Failed 3 minutes ago "task: non-zero exit (255)"
fa9e3qlmcm47 helloworld.2 alpine:latest rancher-worker2 Running Running 30 seconds ago
8mr4dyaga779 helloworld.3 alpine:latest rancher-worker1 Running Running 29 seconds ago
7hbk7w99fo8z helloworld.4 alpine:latest rancher-worker1 Running Running 29 seconds ago
0s7rbd9vwv3r helloworld.5 alpine:latest rancher-home Running Running 35 seconds ago
Remove the service
> docker service rm helloworld
Run and Update the Tomcat Service
> docker service create --replicas 1 --name tomcat-service tomcat:8.5.8
Scale up to 2
> docker service scale tomcat-service=2
Rolling update to tomcat:9.0.33
> docker service update --image tomcat:9.0.33 tomcat-service
Check status
> service ps tomcat-service
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tei2ojnu7jxk tomcat-service.1 tomcat:9.0.33 rancher-worker2 Running Running 33 seconds ago
p6fg4k7l2jie \_ tomcat-service.1 tomcat:8.5.8 rancher-worker2 Shutdown Shutdown 53 seconds ago
q2it5kmfvois tomcat-service.2 tomcat:9.0.33 rancher-home Running Running 55 seconds ago
e3dnf70mx0km \_ tomcat-service.2 tomcat:8.5.8 rancher-home Shutdown Shutdown about a minute ago
r5kvdoruqdcf tomcat-service.3 tomcat:9.0.33 rancher-worker1 Running Running about a minute ago
33j1j47rk4pn \_ tomcat-service.3 tomcat:8.5.8 rancher-worker1 Shutdown Shutdown about a minute ago
Only see 3 history
> docker swarm update --task-history-limit 3
References:
https://yq.aliyun.com/articles/225511
https://outmanzzq.github.io/2019/06/14/portainer-for-docker-swarm/
https://note.qidong.name/2018/11/docker-swarm/
https://www.jianshu.com/p/df744c4e375e
https://github.com/jasonGeng88/blog/blob/master/201704/docker_swarm.md
https://stackoverflow.com/questions/41705134/how-can-i-remove-shutdown-docker-service-tasks-after-a-rolling-update
Maybe an useful tool
https://github.com/docker/machine
发表评论
-
Stop Update Here
2020-04-28 09:00 270I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 439NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 319Docker Swarm 2020(2)Docker Swar ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 298Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 383Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 382Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 337Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 406VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 344Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 425NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 370Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 302Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 215GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 401GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 285GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 274Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 270Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 246Serverless with NodeJS and Tenc ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 307Nginx Deal with OPTIONS in HTTP ...
相关推荐
Docker Swarm 模式集群操作API封装和Swarm UI的中间层应用
The DevOps 2.1 Toolkit Docker Swarm 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请...
Docker Swarm 管理资源.rar
Docker Swarm架构的特性与基本实践.docx
将功能作为服务(在Docker Swarm之上)
Docker Swarm的一个可视化工具 使用 Docker Remote API, Node.JS, 和D3实现
Chapter 1: Welcome to Docker Swarm Chapter 2: Discover the Discovery Services Chapter 3: Meeting Docker Swarm Mode Chapter 4: Creating a Production-Grade Swarm Chapter 5: Administer a Swarm Cluster ...
该资源来自Dockercon 2014“Docker Swarm”。
docker swarm 20.10.17 + portainer-ce 2.14.2 + nginx 1.23.1 一条龙离线包
Docker swarm是一个用于创建Docker主机(运行Docker守护进程的服务器)集群的工具,具备服务发现,负载均衡,任务分发、调度,服务状态一致性保持,滚动更新,安全传输等特性。从docker v1.12开始,docker engine ...
docker swarm部署分布式微服务编排文件示例
第四章:Docker容器升华--swarm集群一、Docker Swarm集群概述;二、Docker Swarm核心架构;三、案例:实现Docker Swarm
Linux运维-运维课程MP4频-05容器-69dockerswarm网络存储卷-nfs准备.mp4
ansible-dockerswarm, 基于"Swarm Mode" 和Ansible的Docker 引擎 Ansible角色:Docker 群 在 Docker/centos和 debian/ubuntu服务器上使用新的Docker"发动机模式群"( https://docs.docker.com/engine/swarm/ ) 建立集
This book explores the practices and tools required to run a Swarm cluster. We'll go beyond a simple deployment. We'll explore how to create a Continuous Deployment process. We'll set up multiple ...
Docker Management Design Patterns explains how to use Docker Swarm mode with Docker Engine to create a distributed Docker container cluster and how to scale a cluster of containers, schedule ...
Ansible-ansible-docker_swarm.zip,负责安装和配置Docker Swarm群集的角色。Docker_Swarm,ansible是一个简单而强大的自动化引擎。它用于帮助配置管理、应用程序部署和任务自动化。
Docker简介 Docker 是一个开源的应用容器引擎,让...docker swarm是一个容器编排管理工具,docker-engine在1.12版本之后集成了docker swarm,不需要再单独安装。 docker swarm的功能,举个例子,有3台机器都安装了do
Jenkins Docker Swarm插件描述该插件允许将Docker Swarm(集群模式)添加为云代理提供程序。 这允许从给定的Docker映像动态启动Docker Swarm中的一次性Jenkins代理。 创建是通过完成的,该允许在代理容器上设置...