Specify Python version when base-notebook is used as a base image

I have a Dockerfile which uses the base-notebook from jupyter/docker-stacks as the base image. I’d like to be able to update the Python version used from 3.7 (the current default) to 3.8. I see that a PYTHON_VERSION argument was added in https://github.com/jupyter/docker-stacks/pull/959.

This works great when building the base-notebook Dockerfile from inside the jupyter/docker-stacks repo. I.e. when running docker build --build-arg PYTHON_VERSION=3.8 base-notebook from the root of the jupyter/docker-stacks repo everything works as expected and Python 3.8 is installed in the built container.

However, this doesn’t seem to work when building an image which uses jupyter/base-notebook as the base image. For example, running

docker build --build-arg PYTHON_VERSION=3.8 Dockerfile

with the following Dockerfile

# Dockerfile
FROM jupyter/base-notebook:lab-1.2.1

does not result in Python 3.8 being used.

Is there a way I can utilize the PYTHON_VERSION argument to use Python 3.8 in a Dockerfile that uses jupyter/base-notebook as the base image?