Creates a container and runs an image in it.

sp_docker_run(image_tag, options = "", command = "", args = "")

Arguments

image_tag

character: a valid image tag (name) for the docker image. If it doesn't exist locally, docker run will try to download it. If the download then fails, the function will stop with an error message.

Note that the full syntax of an image tag is <repository>/<name>:<tag>. For example, the PostgreSQL 10 image we use is docker.io/postgres:10.

options

character: the options to use when running the image. Default is the empty string. You will usually need at least the --name option to give the container a name.

command

character: the command to run after the container boots up. Default is an empty string, which uses the startup command defined in the image.

args

character: the arguments for the command. Default is an empty string.

Value

Result of Docker command if it succeeded. Stops with an error message if it failed.

Details

Do docker run --help in a command prompt to see all the options, of which there are many.

Examples

if (FALSE) { print(sp_docker_run("hello-world")) sp_docker_images_tibble() }