Dockerfile ARG Empty Value Error when Installing Dependencies

I’m facing an issue while trying to build a Docker image with a Dockerfile, and I’m getting an error that looks like this:

ERROR [2/8] RUN pip install 'numpy=='

The problem seems to be related to the use of an ARG, which appears to be empty. Here’s the relevant part of my Dockerfile:

# Use the official Python image as the base image
FROM python:3.8

# Define an ARG for the dependency version

# Attempt to install numpy with the ARG
RUN pip install "numpy==${NUMPY_VERSION}"

I want to be able to specify the NUMPY_VERSION at build time, but it appears to be empty, causing this error. How can I correctly pass the NUMPY_VERSION as an argument when building the Docker image and make sure it’s not empty during the build process?

I google it for you using the search terms “docker build args”, first result is:

I have read over the site before however I still couldn’t figure the solution for it.

The documentation that @meyay linked very clearly shows how to pass a build argument in the “Change runtime versions” section. Are you sure you read the page above and not something else?

I have, the problem is it is within quotations and for some reason it appears as empty when I run it and Docker recognizes it like this: RUN pip install 'numpy=='. I have not found an example in the doc where it shows how I can handle this scenario I guess.

I give you another chance since it is so obvious. Please, go to the end of the section I mentioned in my previous post. Of course it is not using the same variable but it is an example.