run_auto_mount {babelwhale} | R Documentation |
Run a containerised command with automatic mounting of files
Description
Similar to run()
, but automatically mounts files (and directories) so the
user doesn't have to keep track of volumes.
Usage
run_auto_mount(
container_id,
command,
args = NULL,
wd = NULL,
wd_in_container = NULL,
environment_variables = NULL,
debug = FALSE,
verbose = FALSE,
stdout = "|",
stderr = "|"
)
Arguments
container_id |
The name of the container, usually the repository name on dockerhub. |
command |
Character scalar, the command to run. If you are
running |
args |
Character vector, arguments to the command. Any files or directories that should be mounted must be named "file" (see example). |
wd |
Local working directory to run command. If specified, the working directory will be mounted to the docker container. |
wd_in_container |
Working directory to run command in
the container. Defaults to the working directory mounted to the container
( |
environment_variables |
A character vector of environment variables. Format: |
debug |
If |
verbose |
Whether or not to print output |
stdout |
What to do with standard output of the command. Default ( |
stderr |
What to do with standard error of the command. Default ("|") means to include it as an item in the results list.
If it is the empty string ( |
Details
The main difference to run()
is that the use of names for the args
; any
file (or directory) that should be mounted inside the container must be named
file
. The other elements (arguments) don't need to be named. Note that it
is fine to have multiple elements with the same name (file
).
This should generally work as long as the command accepts absolute paths
for file input. If that is not the case, use run()
instead and specify
paths and mounting manually.
Value
List, formatted as output from processx::run()
Examples
if (test_docker_installation()) {
# Count the number of lines in the DESCRIPTION and LICENSE
# files of this package
run_auto_mount(
container_id = "alpine",
command = "wc",
args = c("-l",
file = system.file("DESCRIPTION", package = "babelwhale"),
file = system.file("LICENSE", package = "babelwhale")
)
)
}