Launch and stop Docker

Stop running Docker container

launch_proj_docker(
  path = ".",
  container = "thinkr/rstudio3_6_1_geo",
  network_name = "r-db",
  port = 8787,
  renv_inst = FALSE,
  renv_cache = FALSE,
  renv_out = FALSE,
  renv_out_dir,
  update_docker = TRUE,
  is_root = FALSE,
  volumes,
  open_url = TRUE,
  url = "http://127.0.0.1",
  password = NULL
)

stop_proj_docker(path, sleep = 10, network_name = "r-db", stop_network = TRUE)

Arguments

path

Path to project or any directory to launch.

container

Docker container to download from docker hub.

network_name

Character. Give the name of the network in which the container will be included using --net network_name.

port

Local port to which to launch Rstudio Server

renv_inst

Logical. Whether to add a R script with renv instructions in the project.

renv_cache

Path to renv cache on your computer. Set to FALSE to not use renv.

renv_out

Whether to set renv libraries out of the project.

renv_out_dir

Where to store project libraries. Default to a ".renv" folder in the parent directory of "path"

update_docker

Logical. Whether to update Docker container with DockerHub.

is_root

logical. Whether the Docker user has root permissions (add to sudoers). Can be useful if you want to simulate your CI behaviour in the Terminal using "sudo R".

volumes

data.frame with two columns named local and docker. local contains path to local computer. docker contains path inside the docker container linked to local.

open_url

Logical. Whether to open container URL in browser on http://127.0.0.1:port

url

Localhost url. Default to "http://127.0.0.1". "localhost" can be a good alternative.

password

String. Default to NULL. If not NULL, password will be used as a password to open RStudio server. Useful in case you're using {devindocker} on a remote server.

sleep

Numeric. Number of seconds to wait for user to correctly stop Rstudio Server

stop_network

Logical. Whether to stop Docker network.

Details

renv_out : It is recommended to set renv library out of the project to avoid copy of entire library during package checks. See vignette("packages", package = "renv").

Examples

if (FALSE) { tempdir <- tempdir() path <- file.path(tempdir, "myproject") usethis::create_package(path, open = FALSE) # Which Rstudio container ? ---- container <- c("thinkr/rstudio3_5_2", "rocker/geospatial:4.0.1")[2] # Which port ? ---- # _Useful if multiple Rstudio Server to launch port <- 8788 # _Start Docker project launch_proj_docker(path = path, container = container, port = port) # _Stop Docker properly stop_proj_docker(path = path, sleep = 5) # With renv cache shared with host dir.create(file.path(tempdir, "cache")) tempcache <- file.path(tempdir, "cache") # _Start Docker project launch_proj_docker(path = path, container = container, port = port, renv_cache = tempcache) # _Stop Docker properly stop_proj_docker(path = path, sleep = 5) # Mount with additional volumes }