Home > Back-end >  Podman/Docker Image of Debian not performing sha256sum --check as expected
Podman/Docker Image of Debian not performing sha256sum --check as expected

Time:11-18

I am trying to download a file into a Podman/Docker Image using curl then perform a sha256sum on the file. However, when I use ARGs as defined in the documentation, it doesn't seem to interpolate properly and cause an error of:

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

Here is my working Containerfile.

# 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 --

This however, does not work. While it works in Ubuntu 20.04 Images I've made, it does not work in 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 --

Is there something different I need to be doing to make this work?

CodePudding user response:

Quote from docker documentation:

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

So ARG with values to be used in RUN section should go after 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 --
  • Related