Adds a LABEL
instruction to include metadata in the Docker image.
Details
Labels are key-value pairs that add metadata to your image. They can be used to organize images, record licensing information, annotate build information, or help with image automation.
Common label conventions include:
maintainer
: The person responsible for the imageorg.opencontainers.image.authors
: Image authorsorg.opencontainers.image.version
: Version of the packaged softwareorg.opencontainers.image.source
: URL to the source code
See also
dfi_maintainer()
for the deprecated maintainer instruction &
Official Docker LABEL
documentation
Other dockerfile instruction functions:
dfi_add()
,
dfi_arg()
,
dfi_cmd()
,
dfi_copy()
,
dfi_entrypoint()
,
dfi_env()
,
dfi_expose()
,
dfi_from()
,
dfi_healthcheck()
,
dfi_maintainer()
,
dfi_onbuild()
,
dfi_run()
,
dfi_shell()
,
dfi_stopsignal()
,
dfi_user()
,
dfi_volume()
,
dfi_workdir()
Examples
# Add a single label
df <- dockerfile() |>
dfi_from("rocker/r-ver:4.4.0") |>
dfi_label(maintainer = "user@example.com")
df
#> FROM rocker/r-ver:4.4.0
#> LABEL maintainer="user@example.com"
# Add multiple labels
df <- dockerfile() |>
dfi_from("rocker/r-ver:4.4.0") |>
dfi_label(
maintainer = "user@example.com",
version = "1.0.0",
description = "Example R application",
org.opencontainers.image.source = "https://github.com/user/repo"
)
df
#> FROM rocker/r-ver:4.4.0
#> LABEL maintainer="user@example.com" version="1.0.0" description="Example R application" org.opencontainers.image.source="https://github.com/user/repo"