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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

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 中。