如何自动给 docker image 打标签?

2023-06-13 10:55:55 +08:00
 AaronLee

说明

我使用 Miniflux 作为自己的 RSS 服务器,因为 PostgreSQL 对中文搜索不好,需要在 PostgreSQL 安装 Zhparser 分词插件,目前已经使用 GitHub Action 构建镜像上传到 Docker Hub ,PostgreSQL 运行良好,但也问题。

理想状态

GitHub Action 可以每周自动构建镜像,并上传到 Docker Hub ,如果遇到版本升级,镜像会自动新加一个标签,例子:PostgreSQL 版本为 15.3 ,镜像标签为 15-bullseye 和 15.3-bullseye ,当检测到 PostgreSQL 版本为 15.4 时,生成的镜像标签为 15-bullseye 和 15.4-bullseye ,整个过程要自动运行,不需要人工干预。

一些探索

进入正在运行的 PostgreSQL 容器,发现有环境变量“PG_MAJOR=15”和“PG_VERSION=15.3-1.pgdg110+1”,但不知道怎么用。

目前解决方案

手动查询 PostgreSQL 版本状况,有版本更新时手动处理。

参考

1.仓库链接 Docker Hub

2.Dockerfile GitHub Actions

3.amutu/zhparser

4.fengkx/postgres-docker

1070 次点击
所在节点    Docker
3 条回复
perfectlife
2023-06-13 11:04:21 +08:00
github action 设置每天定时跑一次,去检查一下 pg 有新版本发布没有,有了就用新版本号去 sed 一下 dockerfile 里的旧版本号,然后 build ,push
AaronLee
2023-06-13 11:38:53 +08:00
@perfectlife 你的方案是可以,但超过我的能力范围,我现在处在照着葫芦画瓢,还不一定画的对。
perfectlife
2023-06-13 15:24:48 +08:00
@AaronLee 你可以用这个工具( https://github.com/docker/hub-tool ) 获取镜像 tag


➜ hub-tool hub-tool tag ls postgres
TAG DIGEST STATUS LAST UPDATE LAST PUSHED LAST PULLED SIZE
postgres:latest sha256:3f1669847a14d6a9dede99716a4256cbc08d919a712710883a0d0420aa5e957b active About an hour ago About an hour 5 minutes 1.097GB
postgres:bullseye sha256:dcfdb5d499b04f8d0b4219b07dac07b336923a18255322c95c11d7acd7501aab active About an hour ago About an hour 5 minutes 1.097GB
postgres:16beta1-bullseye sha256:18ebf5ef322333174bf21b4ddc2d2790ccf8ef64c7780a737aeeca8109b37d28 active About an hour ago About an hour 18 minutes 1.113GB
postgres:16beta1 sha256:9288a8bae5d334c63b81ce201c8cff9766db4398b1b561492956aef2b2e6d9f6 active About an hour ago About an hour 18 minutes 1.113GB
postgres:15.3-bullseye sha256:dcfdb5d499b04f8d0b4219b07dac07b336923a18255322c95c11d7acd7501aab active About an hour ago About an hour 5 minutes 1.097GB
postgres:15.3 sha256:dcfdb5d499b04f8d0b4219b07dac07b336923a18255322c95c11d7acd7501aab active About an hour ago About an hour 5 minutes 1.097GB
postgres:15-bullseye sha256:4f97ee9d2bee2cbb8f94be66e9bdfb64804a8f621a89d39c4dfa46c3993afbe5 active About an hour ago About an hour 5 minutes 1.097GB
postgres:15 sha256:dcfdb5d499b04f8d0b4219b07dac07b336923a18255322c95c11d7acd7501aab active About an hour ago About an hour 5 minutes 1.097GB
postgres:14.8-bullseye sha256:5c12a789c541307b6f5dc989107d76feb85555443c43c71be51002212f540e48 active About an hour ago About an hour 5 minutes 1.09GB
postgres:14.8 sha256:5c12a789c541307b6f5dc989107d76feb85555443c43c71be51002212f540e48 active About an hour ago About an hour 5 minutes 1.09GB
postgres:14-bullseye sha256:5c12a789c541307b6f5dc989107d76feb85555443c43c71be51002212f540e48 active About an hour ago About an hour 5 minutes 1.09GB
postgres:14 sha256:5c12a789c541307b6f5dc989107d76feb85555443c43c71be51002212f540e48 active About an hour ago About an hour 5 minutes 1.09GB
postgres:13.11-bullseye sha256:573d0dbcdde4522c6db0a0c50e4f68653c3ba1e70d081cca42d0fee87f67455f active About an hour ago About an hour 4 minutes 1.079GB
postgres:13.11 sha256:573d0dbcdde4522c6db0a0c50e4f68653c3ba1e70d081cca42d0fee87f67455f active About an hour ago About an hour 4 minutes 1.079GB
postgres:13-bullseye sha256:573d0dbcdde4522c6db0a0c50e4f68653c3ba1e70d081cca42d0fee87f67455f active About an hour ago About an hour 4 minutes 1.079GB
postgres:13 sha256:573d0dbcdde4522c6db0a0c50e4f68653c3ba1e70d081cca42d0fee87f67455f active About an hour ago About an hour 4 minutes 1.079GB
postgres:12.15-bullseye sha256:e1ddf56307e5ba4f2ea84972cba6c7c7d4a38eb877ba84d88aa6ed32c5da239d active About an hour ago About an hour 12 minutes 1.076GB
postgres:12.15 sha256:e1ddf56307e5ba4f2ea84972cba6c7c7d4a38eb877ba84d88aa6ed32c5da239d active About an hour ago About an hour 12 minutes 1.076GB
postgres:12-bullseye sha256:e1ddf56307e5ba4f2ea84972cba6c7c7d4a38eb877ba84d88aa6ed32c5da239d active About an hour ago About an hour 12 minutes 1.076GB
postgres:12 sha256:e1ddf56307e5ba4f2ea84972cba6c7c7d4a38eb877ba84d88aa6ed32c5da239d active About an hour ago About an hour 12 minutes 1.076GB
postgres:11.20-bullseye sha256:d2d7021dc4e71399876c2f427172a91c279140d99eafb2322543fc8f1dbe0c2e active 2 hours ago 2 hours 8 minutes 1.068GB
postgres:11-bullseye sha256:d2d7021dc4e71399876c2f427172a91c279140d99eafb2322543fc8f1dbe0c2e active 2 hours ago 2 hours 8 minutes 1.068GB
postgres:16beta1-alpine3.18 sha256:5c0c4788a82f24b5bbdfdee20bb1d2596f5df9e3557b6d62d28737a807bdb7da active 13 days ago 13 days 48 minutes 670.6MB
postgres:16beta1-alpine3.17 sha256:ab0ab8a38bf59e9b96c2f2b2cdd2af8386fd47e9118837cfc63521db6f8fc615 active 13 days ago 13 days 18 minutes 680MB
postgres:16beta1-alpine sha256:11def49016e5c978b95da13b4b4c60b117379e353a4c583b5a5fd873fa7f377d active 13 days ago 13 days 48 minutes 670.6MB
postgres:alpine3.18 sha256:58a4e7ae605e8e247180ebba1cc3758ab20677e9a5221ab3150a74f47938b8a1 active 3 weeks ago 3 weeks 6 minutes 657MB
postgres:alpine3.17 sha256:c1273693a4fa3cbd65e1c3df72b646d50368ab0bdde8a7b35446834b5fa7ff2d active 3 weeks ago 3 weeks 16 minutes 674.2MB
postgres:alpine sha256:58a4e7ae605e8e247180ebba1cc3758ab20677e9a5221ab3150a74f47938b8a1 active 3 weeks ago 3 weeks 6 minutes 657MB
postgres:15.3-alpine3.18 sha256:58a4e7ae605e8e247180ebba1cc3758ab20677e9a5221ab3150a74f47938b8a1 active 3 weeks ago 3 weeks 6 minutes 657MB
postgres:15.3-alpine3.17 sha256:c1273693a4fa3cbd65e1c3df72b646d50368ab0bdde8a7b35446834b5fa7ff2

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/948253

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX