Description
Function to remove the container and/or docker image set up using the
function td_setup_sandbox_env()
.
Notes:
Docker image loaded by the
td_setup_sandbox_env()
function is not removed if there is another container created from the same image. If there is no other container, then image is cleaned up.If user creates a container 'container_1' without using
td_setup_sandbox_env()
function and sets the option 'sandbox.container' with this value, thentd_cleanup_sandbox_env()
function does not remove the container 'container_1' and image associated with it. Onus is on the user to remove the image and associated container manually.If user sets the option 'sandbox.container' manually and runs
td_setup_sandbox_env()
later, then this function resets the option 'sandbox.container' to NULL and performs the cleanup of the container/image created/loaded bytd_setup_sandbox_env()
function.If user runs
td_setup_sandbox_env()
function and then sets the option 'sandbox.container' manually to a different container, then this function cleans up the container/image created/loaded bytd_setup_sandbox_env()
function, but the value of option 'sandbox.container' remains the same.Removing the context or ending the session also performs cleanup similar to this function.
To see if there are any issues while dropping the container and/or image, the user can set the option 'td.debug.enable' to TRUE.
Usage
td_cleanup_sandbox_env()
Value
TRUE, invisibly.
Examples
# Get remote data source connection.
con <- td_get_context()$connection
# Example 1: Setup sandbox environment using td_setup_sandbox_env() function
# and clean it up using td_cleanup_sandbox_env() function.
# This cleans up image and container created by
# td_setup_sandbox_env().
td_setup_sandbox_env(sandbox.image.location = "<path_to_docker_image>",
sandbox.image.name = "rstosandbox:1.0")
td_cleanup_sandbox_env()
# Example 2: Setup sandbox environment using td_setup_sandbox_env() function
# and clean it up using td_cleanup_sandbox_env() function. Then,
# set the option 'sandbox.container' manually to a container
# created from a image different from the one used in
# td_setup_sandbox_env(). This only cleans up image and container
# created by td_setup_sandbox_env() and does NOT clean up the
# container specified in the option.
td_setup_sandbox_env(sandbox.image.location = "<path_to_docker_image>",
sandbox.image.name = "rstosandbox:1.0")
# "<container_1>" is the container NOT created using the image
# "rstosandbox:1.0".
option(sandbox.container = "<container_1>")
td_cleanup_sandbox_env()
# Example 3: Setup sandbox environment using the already created container
# using td_setup_sandbox_env() function and the clean it up using
# td_cleanup_sandbox_env() function. This cleans up only the
# container setup by the td_setup_sandbox_env() function and does
# NOT clean up the image as it is not loaded by the setup.
td_setup_sandbox_env(container = "<container_1>")
td_cleanup_sandbox_env()