Skip to contents

Adds an ADD instruction to copy files, directories, or remote files from source to the container's filesystem at destination.

Usage

dfi_add(dockerfile, src, dest)

Arguments

dockerfile

A dockerfile object

src

Source path (can be a URL or tar archive)

dest

Destination path in the container

Value

An updated dockerfile object with the ADD instruction added

Details

ADD is similar to COPY, but with additional features:

  • If src is a URL, the file is downloaded from the URL

  • If src is a local tar archive, it will be automatically unpacked

Note that COPY is generally preferred for simple file copying because it's more explicit and has fewer side effects than ADD.

See also

dfi_copy() for simpler file copying (generally preferred) & Official Docker ADD documentation

Other dockerfile instruction functions: dfi_arg(), dfi_cmd(), dfi_copy(), dfi_entrypoint(), dfi_env(), dfi_expose(), dfi_from(), dfi_healthcheck(), dfi_label(), dfi_maintainer(), dfi_onbuild(), dfi_run(), dfi_shell(), dfi_stopsignal(), dfi_user(), dfi_volume(), dfi_workdir()

Examples

# Add a local file
df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0") |>
  dfi_add("local.txt", "/app/local.txt")
  
# Add a file from a URL
df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0") |>
  dfi_add("https://example.com/file.txt", "/app/file.txt")