Is this a docs issue?
Type of issue
Information is incorrect
Description
Environment replacement documentation is missing the following bash string parameter substitution modifier:
Per 10.2. Parameter Substitution - The Linux Documentation Project
"${parameter-default} and ${parameter:-default} are almost equivalent. The extra : makes a difference only when parameter has been declared, but is null.
Meaning that if you want to set a default for an environment variable ONLY if it is not declared, but not null, you must use - without the :. For example:
-
# Dockerfile
ARG HTTP_PROXY
ENV http_proxy=${HTTP_PROXY-http://my-proxy.com:1234}
RUN echo $http_proxy
# No build arg
$ docker build -f Dockerfile .
> http://my-proxy.com:1234
# Build arg null (this is the difference!)
$ docker build --build-arg HTTP_PROXY="" -f Dockerfile .
>
# Build arg value
$ docker build --build-arg HTTP_PROXY="override" -f Dockerfile .
> override
:-
# Dockerfile
ARG HTTP_PROXY
ENV http_proxy=${HTTP_PROXY:-http://my-proxy.com:1234}
RUN echo $http_proxy
# No build arg
$ docker build -f Dockerfile .
> http://my-proxy.com:1234
# Build arg null (this is the difference!)
$ docker build --build-arg HTTP_PROXY="" -f Dockerfile .
> http://my-proxy.com:1234
# Build arg value
$ docker build --build-arg HTTP_PROXY="override" -f Dockerfile .
> override
Tested and confirmed locally.
Location
https://docs.docker.com/reference/dockerfile/#environment-replacement
Suggestion
Update documentation to include the ${variable-word} bash string parameter substitution modifier.
Is this a docs issue?
Type of issue
Information is incorrect
Description
Environment replacement documentation is missing the following bash string parameter substitution modifier:
${variable-word}Per 10.2. Parameter Substitution - The Linux Documentation Project
Meaning that if you want to set a default for an environment variable ONLY if it is not declared, but not null, you must use
-without the:. For example:-:-Tested and confirmed locally.
Location
https://docs.docker.com/reference/dockerfile/#environment-replacement
Suggestion
Update documentation to include the
${variable-word}bash string parameter substitution modifier.