harbor (version 0.2.0)

docker_run: Run a command in a new container on a host.

Description

Run a command in a new container on a host.

Usage

docker_run(host = localhost, image = NULL, cmd = NULL, name = NULL,
  rm = FALSE, detach = FALSE, docker_opts = NULL, capture_text = FALSE,
  ...)

Arguments

host

An object representing the host where the container will be run.

image

An `image` object or the name or ID of a docker image.

cmd

A command to run in the container.

name

A name for the container. If none is provided, a random name will be used.

rm

If TRUE, remove the container after it finishes. This is incompatible with detach=TRUE.

detach

If TRUE, run the container in the background.

docker_opts

Options to docker. These are things that come before the docker command, when run on the command line.

capture_text

If FALSE (the default), return the host object. This is useful for chaining functions. If TRUE``, capture the text output from both stdout and stderr, and return that. Note thatTRUE`` may not be available on all types of hosts.

...

Other arguments passed to the SSH command for the host

Value

A container object. When rm=TRUE, this function returns NULL instead of a container object, because the container no longer exists.

Examples

Run this code
# NOT RUN {
docker_run(localhost, "debian:testing", "echo foo")
#> foo

# Arguments will be concatenated
docker_run(localhost, "debian:testing", c("echo foo", "bar"))
#> foo bar

docker_run(localhost, "rocker/r-base", c("Rscript", "-e", "1+1"))
#> [1] 2
# }

Run the code above in your browser using DataCamp Workspace