3

docker 服务部署随记

 3 years ago
source link: http://www.hechunbo.com/index.php/archives/396.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

swarm集群要保证三台机器 可用.

docker swarm init  --advertise-add ip  #别人如果加入,复制下面的那一句话。

docker swarm leave --force 
docker node ls #列出当前节点,只能在manager上运行. 

docker service create --replicas 1 --name hellowrd alpine ping docker.com 
#alpine ping docker.com  将服务定义为执行命令ping docker.com 的alpine linux容器

#动态扩缩容器
#创建三个helloworld副本, 随机部署到集群里的服务器,不管访问哪个节点都可以访问到. 
docker service update --replicas 3 helloworld 

docker service update --replicas 1 helloworld

#scale 与udpdate --replicas 等价
docker service scale helloworld=5
docker service scale helloworld=2

#查看更新的服务列表
docker service ps helloworld 

docker stack

为了解决大规模场景下的多服务器部署和管理,提供了期望状态,滚动升级,简单易用,扩缩容,健康检查.
根据docker-stack.yml 文件,使用docker stack deploy部署
docker 用于开发和测试
docker stack 用于大规模场景和生产环境

docker stack vs docker compose

一个用于生产环境,不能build -docker stack

一个用于开发,测试环境 , 可以build 自动创建镜像.-docker compose

https://www.cnblogs.com/JulianHuang/p/11599170.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK