I have a simple Dockerfile:
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}
If I do something like export PYTHON_VERSION=3.11
and sudo docker build --build-arg PYTHON_VERSION .
, Docker returns an invalid reference format
error. On the other hand, sudo docker build --build-arg PYTHON_VERSION=$PYTHON_VERSION .
works as intended.
This seems contradictory to Docker's documentation:
You may also use the --build-arg flag without a value, in which case the value from the local environment will be propagated into the Docker container being built:
export HTTP_PROXY=http://10.20.30.2:1234 docker build --build-arg HTTP_PROXY .
The version of docker I'm using is 20.10.23
. What's wrong here?