Adds a CMD
instruction to provide defaults for an executing container.
These defaults can be executable programs or commands to be executed when
the container starts.
Details
The function automatically converts the command to JSON array format, which
is the recommended approach for better signal handling.
Only one CMD
instruction is effective in a Dockerfile; if multiple are specified,
only the last one will take effect.
See also
dfi_entrypoint()
for defining the main executable of the container,
dfi_run()
for executing commands during the build, &
Official Docker CMD
documentation
Other dockerfile instruction functions:
dfi_add()
,
dfi_arg()
,
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
# Simple command
df <- dockerfile() |>
dfi_from("rocker/r-ver:4.4.0") |>
dfi_copy("script.R", "/app/script.R") |>
dfi_cmd("Rscript /app/script.R")
# Array format (recommended)
df <- dockerfile() |>
dfi_from("rocker/r-ver:4.4.0") |>
dfi_cmd(c("R", "--no-save"))