hashcontainer-file

Should I / how to retrieve miniconda installer SHA256 programatically?


I am setting up a Containerfile that should install miniconda.

The instructions for installing miniconda are available at: https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html .

I am able to get the installer from https://docs.anaconda.com/miniconda/ as:

RUN wget --https-only https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
RUN bash Miniconda3-latest-Linux-x86_64.sh -b

However, one thing is missing here: checking the SHA256 hash of the .sh installer. I know where the SHA is (it is on https://docs.anaconda.com/miniconda/ ), however, I do not see a simple way to retrieve it programatically.

Any idea how I can do this?


Solution

  • A solution would be to download the Miniconda hashes to a file, then see if the hash you generated is in the file.

    The SHA-256 hashes for Miniconda are located on the download page at:

    https://repo.anaconda.com/miniconda/

    So, the Docker commands would be:

    RUN wget --https-only https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    RUN checksum_string=$(bash sha256sum Miniconda3-latest-Linux-x86_64.sh)
    RUN wget -O miniconda_hashes.html "https://repo.anaconda.com/miniconda/"
    RUN if grep -q "$checksum_string" miniconda_hashes.html; then \
            echo "Miniconda checksum verified." ; \
        else \
            echo "Miniconda checksum was not verified. Exiting." && exit 1; \
        fi