Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ARG, ENV and LABEL reference definitions #5434

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

thompson-shaun
Copy link
Collaborator

Follow-up to suggestion from @thaJeztah in #5427

Update ARG and ENV syntax definitions to clarify that first KV-pair is required but additional ones are optional

Copy link
Collaborator

@dvdksn dvdksn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but we should also update it for LABEL

… KV-pairs are required but additional ones are optional

Signed-off-by: Shaun Thompson <[email protected]>
@thompson-shaun thompson-shaun force-pushed the update-env-arg-ref-defs branch from 2f0a2ae to 5379646 Compare October 18, 2024 11:59
@thompson-shaun thompson-shaun changed the title Update ARG and ENV reference definitions Update ARG, ENV and LABEL reference definitions Oct 18, 2024
@thompson-shaun
Copy link
Collaborator Author

LGTM but we should also update it for LABEL

Added LABEL, great catch @dvdksn 🫡

@thaJeztah
Copy link
Member

Ah, thanks! I had the tab still open as reminder, but didn't get round to opening a PR.

Changes LGTM; one more thing (but doesn't have to be in this PR) I was considering, but I still had to read up on the current docs, is to make sure we properly outline the distinction between "value is set" and "no value" (ARG FOO= vs ARG FOO).

Something along the lines of;

A default value can be set, but may be empty. The following example declares the FOO arg with an empty default;

ARG FOO=

If the value is omitted, the default is looked up from environment (ENV) defined in the Dockerfile or its parent images, but can be overridden through the --build-arg command-line option. If no value is found, the ARG is unset.

docker build --progress=plain -<<'EOF'
# syntax=docker/dockerfile:1

# nginx:alpine defines a NGINX_VERSION env-var
FROM nginx:alpine
ARG FOO_UNSET
ARG FOO_EMPTY=
ARG NGINX_VERSION
RUN printenv | grep -E '(FOO|NGINX)'
EOF
#5 [2/2] RUN printenv | grep -E '(FOO|NGINX)'
#5 0.238 FOO_EMPTY=
#5 0.238 NGINX_VERSION=1.27.2
docker build --build-arg NGINX_VERSION=override --progress=plain -<<'EOF'
# syntax=docker/dockerfile:1

# nginx:alpine defines a NGINX_VERSION env-var
FROM nginx:alpine
ARG FOO_UNSET
ARG FOO_EMPTY=
ARG NGINX_VERSION
RUN printenv | grep -E '(FOO|NGINX)'
EOF
#5 [2/2] RUN printenv | grep -E '(FOO|NGINX)'
#5 0.221 FOO_EMPTY=
#5 0.221 NGINX_VERSION=override

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tonistiigi tonistiigi merged commit f835dd4 into moby:master Oct 18, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants