Podman/Docker Debian 图像未按预期执行 sha256sum --check

Podman/Docker Image of Debian not performing sha256sum --check as expected

我正在尝试使用 curl 将文件下载到 Podman/Docker 图像中,然后对该文件执行 sha256sum。但是,当我使用文档中定义的 ARGs 时,它似乎无法正确插值并导致错误:

sha256sum: 'standard input': no properly formatted SHA256 checksum lines found

这是我的工作容器文件。

# ARGs
ARG DEB_RELEASE=bullseye
ARG AZ_FUNC_VERSION=4
ARG NEOVIM_VERSION=v0.5.1
ARG NEOVIM_SHA256=1cfbc587ea5598545ac045ee776965a005b1f0c26d5daf5479b859b092697439

FROM docker.io/library/debian:${DEB_RELEASE}

RUN curl --location --remote-name --url "https://github.com/neovim/neovim/releases/download/v0.5.1/nvim.appimage" && \
    echo "1cfbc587ea5598545ac045ee776965a005b1f0c26d5daf5479b859b092697439  nvim.appimage" | sha256sum --check --

然而,这不起作用。虽然它在我制作的 Ubuntu 20.04 Images 中有效,但在 Debian 中无效。

# ARGs
ARG DEB_RELEASE=bullseye
ARG AZ_FUNC_VERSION=4
ARG NEOVIM_VERSION=v0.5.1
ARG NEOVIM_SHA256=1cfbc587ea5598545ac045ee776965a005b1f0c26d5daf5479b859b092697439

FROM docker.io/library/debian:${DEB_RELEASE}

RUN curl --location --remote-name --url "https://github.com/neovim/neovim/releases/download/${NEOVIM_VERSION}/nvim.appimage" && \
    echo "${NEOVIM_SHA256}  nvim.appimage" | sha256sum --check --

为了完成这项工作,我需要做些什么不同的事情吗?

引自 docker 文档:

An ARG declared before a FROM is outside of a build stage, so it can’t be used in any instruction after a FROM. To use the default value of an ARG declared before the first FROM use an ARG instruction without a value inside of a build stage

所以 ARGRUN 部分中使用的值应该放在 FROM.

之后
# ARGs for FROM section
ARG DEB_RELEASE=bullseye
FROM docker.io/library/debian:${DEB_RELEASE}
# ARGs to be used in RUN command
ARG AZ_FUNC_VERSION=4
ARG NEOVIM_VERSION=v0.5.1
ARG NEOVIM_SHA256=1cfbc587ea5598545ac045ee776965a005b1f0c26d5daf5479b859b092697439
RUN curl --location --remote-name --url "https://github.com/neovim/neovim/releases/download/${NEOVIM_VERSION}/nvim.appimage" && \
    echo "${NEOVIM_SHA256}  nvim.appimage" | sha256sum --check --