Skip to contents

Adds one or more ENV instructions to set environment variables in the container.

Usage

dfi_env(dockerfile, ...)

Arguments

dockerfile

A dockerfile object

...

Named environment variables

Value

An updated dockerfile object with ENV instructions added

Details

Environment variables set with ENV persist throughout the container's runtime. Each variable is added as a separate ENV instruction in the Dockerfile, making it easier to track changes in the Docker build history.

See also

Examples

# Add a single environment variable
df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0") |>
  dfi_env(PATH = "/usr/local/bin:$PATH")
df
#> FROM rocker/r-ver:4.4.0
#> ENV PATH /usr/local/bin:$PATH 
 
# Add multiple environment variables
df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0") |>
  dfi_env(
    DEBIAN_FRONTEND = "noninteractive",
    TZ = "America/Chicago",
    LANG = "en_US.UTF-8"
  )
df
#> FROM rocker/r-ver:4.4.0
#> ENV DEBIAN_FRONTEND noninteractive
#> ENV TZ America/Chicago
#> ENV LANG en_US.UTF-8