Skip to contents

Replaces a line at the specified position with new content.

Usage

dfm_replace_line(dockerfile, line_num, new_line)

Arguments

dockerfile

A dockerfile object

line_num

Line number to replace

new_line

New line content

Value

An updated dockerfile object with the specified line replaced

See also

dfm_add_line() for adding a line & dfm_remove_line() for removing a line

Other dockerfile modification functions: dfm_add_line(), dfm_group_similar(), dfm_move_line(), dfm_remove_line(), dfm_sort_by_instruction()

Examples

df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0") |>
  dfi_run("apt-get update")
  
# Replace the RUN instruction with a more comprehensive one
df <- dfm_replace_line(df, 2, 
  "RUN apt-get update && apt-get install -y libcurl4-openssl-dev && apt-get clean")