Docker alpine apk 找不到 git-lfs 包

Docker alpine apk cannot find git-lfs package

我正在尝试在 Docker alpine 映像中安装 git-lfs,但我收到一条错误消息:

ERROR: unsatisfiable constraints:
git-lfs (missing):
required by: world[git-lfs]

似乎出现了很多与 apk 找不到包相关的问题(参见 and ), and in many cases these have been solved by using the --no-cache option with apk add. But I am not being that lucky and cannot understand the origin of this error, specially considering that git-lfs is up to date in alpine repo

以下小 Docker 文件应该重现错误:

FROM alpine:3.4

RUN apk update && apk add --no-cache \
        build-base \
        git \
        git-lfs

问题是 git-lfs 只能从 alpine:3.7.

获得

要解决此问题,您应该自行重建它或使用 >=3.7 的 alpine 版本。

顺便说一句,你不需要执行 apk update.