The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Title: Containerize Your 'R' Project
Version: 0.1.3
Description: Provides tools for containerizing 'R' projects. The core function, 'generate_dockerfile()', analyzes an 'R' project's environment and dependencies via an 'renv' lock file and generates a ready-to-use 'Dockerfile' that encapsulates the computational setup. Designed to help researchers build portable, reproducible workflows that can be reliably shared, archived, and rerun across systems. See R Core Team (2025) https://www.R-project.org/, Ushey et al. (2025) https://CRAN.R-project.org/package=renv, and Docker Inc. (2025) https://www.docker.com/.
License: Apache License (≥ 2)
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.2
URL: https://github.com/erwinlares/containr, https://erwinlares.github.io/containr/
BugReports: https://github.com/erwinlares/containr/issues
Suggests: spelling, testthat (≥ 3.0.0), withr
Imports: cli, dplyr, glue, httr, purrr, readr
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-04-26 04:45:17 UTC; lares
Author: Erwin Lares ORCID iD [aut, cre]
Maintainer: Erwin Lares <erwin.lares@wisc.edu>
Repository: CRAN
Date/Publication: 2026-04-26 06:50:02 UTC

containr: Containerize Your 'R' Project

Description

logo

Provides tools for containerizing 'R' projects. The core function, 'generate_dockerfile()', analyzes an 'R' project's environment and dependencies via an 'renv' lock file and generates a ready-to-use 'Dockerfile' that encapsulates the computational setup. Designed to help researchers build portable, reproducible workflows that can be reliably shared, archived, and rerun across systems. See R Core Team (2025) https://www.R-project.org/, Ushey et al. (2025) https://CRAN.R-project.org/package=renv, and Docker Inc. (2025) https://www.docker.com/.

Author(s)

Maintainer: Erwin Lares erwin.lares@wisc.edu (ORCID)

See Also

Useful links:


Retrieve Docker tags for a Rocker image

Description

Queries the Docker Hub API to retrieve all available tags for a specified Rocker image. Supports user-friendly modes: "base", "rstudio", and "tidyverse". Returns a structured list containing the image name, tag vector, and source URL.

Usage

.get_r_ver_tags(r_mode = "base", verbose = FALSE)

Arguments

r_mode

Character string. One of "base", "rstudio", or "tidyverse". Determines which Rocker image to query. "base" maps to "rocker/r-ver".

verbose

Logical. If TRUE, prints progress messages during tag retrieval and pagination.

Value

A named list with the following elements:

image

Character string. The full Docker image name, e.g. "rocker/r-ver".

tags

Character vector. All available tags for the specified image, e.g. c("latest", "devel", "4.4", "4.4.3", ...).

source

Character string. The base URL of the Docker Hub API used to retrieve the tags.


Check if a specific Rocker image tag exists

Description

Validates the format of a version string and checks whether it exists among the available tags for a specified Rocker image on Docker Hub. Supports semantic versioning, CUDA variants, and Ubuntu suffixes.

Usage

.r_ver_exists(version, r_mode = "base", verbose = FALSE)

Arguments

version

Character string. The tag to check for existence, e.g. "4.4.0", "devel", or "4.4.0-cuda12.2-ubuntu22.04". Must match semantic versioning or be one of "latest", "devel".

r_mode

Character string. One of "base", "rstudio", or "tidyverse". Determines which Rocker image to query.

verbose

Logical. If TRUE, prints messages indicating whether the version was found.

Value

Logical. TRUE if the specified version tag exists for the given Rocker image; otherwise FALSE.


Validate a file argument

Description

Internal helper used by generate_dockerfile() to check that optional file arguments (e.g. data_file, code_file, misc_file) are valid.

Usage

.validate_file_arg(arg_name, value)

Arguments

arg_name

Character string, the name of the argument being checked (used only in error messages).

value

A character path to a file, or NULL.

Value

A normalized file path if validation succeeds, or NULL if the input was NULL.


Generate a reproducible Dockerfile for an R project

Description

generate_dockerfile() inspects an R project's dependencies via an renv lockfile and writes a ready-to-use Dockerfile to the specified output directory. It supports multiple Rocker base images, optional system libraries, Quarto installation, file copying, user creation, and inline documentation comments.

Usage

generate_dockerfile(
  verbose = FALSE,
  r_version = "current",
  data_file = NULL,
  code_file = NULL,
  misc_file = NULL,
  add_user = NULL,
  home_dir = "/home",
  install_quarto = FALSE,
  expose_port = "8787",
  r_mode = "base",
  install_syslibs = TRUE,
  comments = FALSE,
  output = tempdir()
)

Arguments

verbose

Logical. If TRUE, prints progress messages as each section of the Dockerfile is written. Defaults to FALSE.

r_version

A character string specifying the R version to use, e.g. "4.3.0". Defaults to "current", which resolves to the version of R running in the current session.

data_file

A character string. Path to an optional data file to copy into the container under ⁠/home/data/⁠. Defaults to NULL.

code_file

A character string. Path to an optional script file (e.g. .R, .qmd, .rmd) to copy into the container under ⁠/home/⁠. Defaults to NULL.

misc_file

A character string. Path to an optional miscellaneous file (e.g. an image or shell script) to copy into the container under ⁠/home/⁠. Defaults to NULL.

add_user

A character string. Name of a Linux user to create inside the container with sudo access. Defaults to NULL.

home_dir

A character string. The working directory set inside the container via WORKDIR. Defaults to "/home".

install_quarto

Logical. If TRUE, downloads and installs the Quarto CLI inside the container. Defaults to FALSE.

expose_port

A character string. The port to expose when r_mode is "rstudio". Defaults to "8787".

r_mode

A character string selecting the Rocker base image. Inspired by the Rocker Project. One of "base" for plain R, "tidyverse" for R with the tidyverse, "rstudio" for RStudio Server, or "tidystudio" for tidyverse plus TeX Live and publishing-related packages. Defaults to "base".

install_syslibs

Logical. If TRUE, installs system libraries commonly required by R packages and needed for source compilation (e.g. libcurl4-openssl-dev, libxml2-dev). Defaults to TRUE.

comments

Logical. If TRUE, annotates each Dockerfile instruction with an explanatory comment. Useful for learning or sharing. Defaults to FALSE.

output

A character string. Directory path where the Dockerfile will be written. Defaults to tempdir().

Value

Called for its side effects. Writes a Dockerfile to output. Does not return a value.

Examples

# Generate a minimal Dockerfile using a pinned R version
generate_dockerfile(r_version = "4.4.0", output = tempdir())

# Pin a specific R version with the tidyverse image
generate_dockerfile(r_version = "4.3.0", r_mode = "tidyverse", output = tempdir())

# Include a data file and annotate the Dockerfile with comments
## Not run: 
generate_dockerfile(
  r_version = "4.3.0",
  data_file = "data/penguins.csv",
  comments  = TRUE,
  output    = "."
)

## End(Not run)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.