威联通容器自动更新方法
因为威联通的容器管理站没有定期检测自动更新容器的功能 所以使用watchtower工具来实现此功能。
对于此功能并没有经过精细的研究只能说just work。使用威联通容器工作站的创建功能添加下列yaml。
version: "3"
services:
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: nginx redis --cleanup --schedule "0 0 4 * * *"
需要修改的部分为 command: nginx redis --cleanup --schedule "0 0 4 * * *"
将 command: 后面的 nginx redis 这部分改为你需要更新的容器名称
注意是你已经建立的容器名称不是镜像名称
--schedule "0 0 4 * * *" 这部分是cron 格式的时间表达式
该时间表达式由六个字段组成,它们按顺序表示了任务的执行时间:
秒 分 时 日 月 星期 按需修改
例如 0 0 7 * * 3
此表达式为每周三早上七点更新
评论
评论由 Giscus 提供,需要 GitHub 账号。滚动到这里时自动加载。