Reputation: 11140
I have a Dockerfile that starts out...
FROM some.artifactory.example.com/openjdk:8-jre-alpine
ARG version
LABEL version=$version
...
I'd like to know what 'version' and '$version' are and what their utility is as the values to ARG and LABEL respectively. Like does ARG version
somehow pull some value "in scope" and then LABEL version=$version
use that...to what end? Nowhere else in the Dockerfile in question do I see any mention of version.
Upvotes: 0
Views: 3659
Reputation: 56627
A LABEL
is a piece of metadata on an image. You can add any key=val
as a LABEL.
An ARG
is something you can pass at build time, to the builder. You can then use the value in your Dockerfile during the build (but it is no longer available at runtime; so unless you somehow persist the value into the image itself, the container will have no idea what the value was).
docker build --build-arg version=1.2.3
Based on this Dockerfile, it looks like the author wanted to pass a version number at build time, and persist that in the metadata. They used the ARG
(and --build-arg
) to pass in the value, and they used the LABEL
to store it in the resulting image, as metadata.
In other words, this appears to be some sort of organization / bookkeeping for the image, but it has no effect on the image's contents or runtime characteristics.
Upvotes: 2