Skip to content

ci(docker): 临时探针——定位镜像 apt 层的 update-alternatives 失败 - #110

Closed
ReSerendipity wants to merge 1 commit into
mainfrom
fix/docker-apt-manpages
Closed

ReSerendipity wants to merge 1 commit into
mainfrom
fix/docker-apt-manpages

Conversation

@ReSerendipity

Copy link
Copy Markdown
Owner

这条 PR 现在只是诊断,不是修复;探针文件在定位后会被同一个 PR 里删掉。

要解决的问题

main 从 12:19 起 Build & Scan Image 与 Boot hardened container & probe 确定性红在
apt-get 阶段:

update-alternatives: error: alternative path /usr/share/man/man7/bash-builtins.7.gz doesn't exist
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends ..."

判据链(说明它不是某个 PR 引入的):main 11:07 的同类构建还是 success(41f5a12),
之后两次 PR 构建 + 各一次重试全红在同一步;#107/#108 都没碰 Dockerfile。

为什么先做探针而不是直接改 Dockerfile

  1. 本机没有 docker daemon(只有 CLI,也没有 colima/podman)—— 改完我无法自验;
  2. 用 docker-build.yml 当试错循环,一轮 20+ 分钟还会把两条安全门禁反复刷红;
  3. 这个作业在托管 runner 的 container job 里拉同一个基础镜像,把 Dockerfile 的 apt 层拆成
    A/B/C 三段逐条跑,几分钟就能定位是哪一段、哪个包;失败时自动 dump:
    谁维护这条 alternative、bash/man-db/manpages 的 dpkg 状态、/usr/share/man 现状、
    apt-get -s upgrade 会动到谁、相关 postinst 里有没有 update-alternatives 调用。

主要嫌疑是 runtime 段那句 apt-get upgrade -y:它会把 bash / man-db / manpages 一起升上来,
而两处 --no-install-recommends 又可能让 man-db 的配套不完整。拆开跑就能证实或排除。

之后

定位到根因就在这条 PR 里给出真修复(而不是 path-exclude 之类未经验证的规避),
并删掉探针文件;修复要在完整镜像构建上验绿才算完,不接受"看起来合理"。

main 的 `Build & Scan Image` 与 `Boot hardened container & probe` 从 12:19 起确定性失败在
`apt-get` 阶段:`update-alternatives: error: alternative path
/usr/share/man/man7/bash-builtins.7.gz doesn't exist`(重试两次一模一样,与 PR 内容无关)。

不在 Dockerfile 上盲改的理由有两条:① 本机没有 docker daemon(只有 CLI,也没有
colima/podman),改完无法自验;② `docker-build.yml` 一轮 20+ 分钟(25 GB 上下文 + Trivy),
拿它当试错循环既慢又把两条门禁反复刷红。

所以先花几分钟跑这个探针:在托管 runner 的 container job 里用**同一个基础镜像**
(nvidia/cuda:12.1.0-runtime-ubuntu22.04),把 Dockerfile 的 apt 层拆成 A/B/C 三段逐条执行,
失败时 dump 出:谁维护这条 alternative、bash/man-db/manpages 的 dpkg 状态、
/usr/share/man 现状、`apt-get -s upgrade` 会动到谁、相关 postinst 里有没有 update-alternatives。
主要嫌疑是 runtime 段那句 `apt-get upgrade -y`(它会把 bash/man-db/manpages 一起升上来,
而 `--no-install-recommends` 又可能没装 man-db 的配套),三段拆开就能定位。

定位完成后删掉本文件 —— 它是一次性探针,不是常开门禁。

Signed-off-by: ReSerendipity <zengyangc@outlook.com>
@ReSerendipity

Copy link
Copy Markdown
Owner Author

已由 #111 接替(本 PR 的根因假设被自己的探针数据证伪)。

ReSerendipity added a commit that referenced this pull request Sep 21, 2026
先前这里写的是"确定性基础设施故障、jammy 归档期的 man-db/manpages 组合"。两条都不成立:
探针 PR #110 五步全绿,而绿色 run 35607107888 里同样出现了那条 update-alternatives error。
本仓 FIX_LOG.md(2026-09-11 行)与 docs/agents/GOTCHAS.md #113 早就写着它是非致命噪声 ——
定位开工前没查自己的记录,等于用新猜测推翻了旧的正确结论。

Signed-off-by: ReSerendipity <zengyangc@outlook.com>
@ReSerendipity

Copy link
Copy Markdown
Owner Author

更正:这条 PR 的根因假设是错的,别照它改 Dockerfile

我开这条探针时要验证的假设是:镜像构建间歇性失败的根因是
update-alternatives: error: alternative path /usr/share/man/man7/bash-builtins.7.gz doesn't exist。

探针把它证伪了:5 步全绿(同一基础镜像 nvidia/cuda:12.1.0-runtime-ubuntu22.04,
逐条跑 Dockerfile 的三段 apt,包括头号嫌疑 apt-get upgrade -y)。

而且我漏看了现成的反证 —— 同仓 FIX_LOG.md(2026-09-11 行)和 docs/agents/GOTCHAS.md #113
早就写着那条 bash-builtins error 是非致命噪声。对比日志 further confirms:
成功的 run 35607107888 在 13:42:31(#11 97.72)同样打印了这条 error,构建照样绿。

红 run(35598902698 / 35599696780)的真 fatal 是:

Ign:7 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 Packages
W: Some index files failed to download. They have been ignored, or old ones used instead.
   ← apt-get update 在这里返回 0,静默降级就发生在这一格
E: Unable to locate package python3.12
E: Unable to locate package python3.12-venv

绿色 run 同一行是 Get:7 ... Packages [44.3 kB]。也就是说决定成败的是 deadsnakes 索引抓没抓到,
而 apt 对"某个索引没抓下来"只给 W: 不报错。

这条 PR 的价值到此为止(一次性诊断作业,不合入),修复与验收见 #111。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant