惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

docker on 打工人日志

DockerHub 加速镜像部署 - 使用cloudflare 代理 清理Docker容器日志 contained 安装及使用 docker 命令(2) 清理Docker的container,image与volume docker 和 docker-compose 安装 docker 安装kong 网关 搭建docker registry 镜像仓库 docker image镜像上传 docker进阶使用
docker的零停机部署
2024-04-01 · via docker on 打工人日志

本页内容


docker的零停机部署

背景

使用 docker compose up 部署新版本的服务会导致停机,因为应用容器在创建新容器之前已停止。如果你的应用程序需要一段时间才能启动,用户可能会注意到这一点。为了保障服务用户无感,可以使用docker rollout

适合没必要用 K8S 轻量级小项目

安装

项目地址

1# 为 Docker cli 插件创建目录
2mkdir -p ~/.docker/cli-plugins
3
4# 下载 docker-rollout 脚本到 Docker cli 插件目录
5curl https://github.jobcher.com/gh/https://raw.githubusercontent.com/wowu/docker-rollout/master/docker-rollout -o ~/.docker/cli-plugins/docker-rollout
6
7# 使脚本可执行
8chmod +x ~/.docker/cli-plugins/docker-rollout

使用

注意事项!!!

  • 服务不能在 docker-compose.yml 中定义 container_nameports ,因为不可能运行具有相同名称或端口映射的多个容器。
  • 需要像 Traefiknginx-proxy 这样的代理来路由流量。
  • 每次部署都会增加容器名称中的索引(例如 project-web-1 -> project-web-2

使用示范

1# 下载代码
2git pull
3# 构建新的应用程序映像
4docker compose build web
5# 运行数据库迁移
6docker compose run web rake db:migrate
7# 部署新版本
8docker rollout web

或者使用docker-compose.yaml

1docker rollout -f docker-compose.yml <service-name>

参数

  • -f | –file FILE - (非必需)- 撰写文件的路径,可以多次指定,如 docker compose 中。
  • -t | –timeout SECONDS -(非必需)- 如果容器在 Dockerfile 或 docker-compose.yml 中定义了运行状况检查,则等待新容器变得健康的超时时间(以秒为单位)。默认值:60
  • -w | –wait SECONDS - (非必需)- 如果未定义 healthcheck,则等待新容器准备就绪的时间。默认值:10
  • –env-file FILE - (非必需)- env 文件的路径,可以多次指定,如 docker compose 中。