pub struct Driver { /* private fields */ }Expand description
Container driver.
Implementations§
Source§impl Driver
impl Driver
Sourcepub fn from_config(
isolation_group_id: String,
config: DriverConfig,
) -> Result<Self, GenericError>
pub fn from_config( isolation_group_id: String, config: DriverConfig, ) -> Result<Self, GenericError>
Creates a new Driver from the given isolation group ID and configuration.
§Isolation group
The isolation group ID serves as a unique identifier to be used for both the name of the container as well as the shared resources that are created and attached to the container. If two drivers share the same isolation group ID, the containers they spawn will be located in the same network namespace, have access to the same shared Airlock volume, etc.
§Shared volume
The container will have a volume bind-mounted at /airlock that is shared between all containers in the same
isolation group. This volume is mounted as world writeable (777) so all containers can freely read and write to
it. This makes it easier for containers to share data between one another, but also means that care should be
taken to avoid conflicts between trying to write to the same file, etc.
§Errors
If the Docker client cannot be created/configured, an error will be returned.
Sourcepub fn with_logging(self, log_dir: PathBuf) -> Self
pub fn with_logging(self, log_dir: PathBuf) -> Self
Configures the driver to capture container logs.
The logs will be stored in the given directory, under a subdirectory named after the isolation group ID. Each
container will get a log for standard output and standard error, following the pattern of <container name>.[stdout|stderr].log.
Sourcepub fn driver_id(&self) -> &'static str
pub fn driver_id(&self) -> &'static str
Returns the string identifier of the driver.
This is generally a shorthand of the application/service, such as dogstatsd or millstone.
Clean up any containers, networks, and volumes related to the given isolation group ID.
This is a free function to facilitate cleaning up resources after a number of drivers are run.
§Errors
If the Docker client cannot be created/configured, or there is an error when finding or removing any of the related resources, an error will be returned.
Sourcepub async fn start(&mut self) -> Result<DriverDetails, GenericError>
pub async fn start(&mut self) -> Result<DriverDetails, GenericError>
Starts the container, creating any necessary resources.
§Errors
If there is an error while creating the network or shared volume, while pulling the container image, or while creating or starting the container, it will be returned.
Sourcepub async fn wait_for_container_healthy(&mut self) -> Result<(), GenericError>
pub async fn wait_for_container_healthy(&mut self) -> Result<(), GenericError>
Waits until the container is marked as healthy.
If the container has no health checks defined, this returns early and does no waiting.
§Errors
If there is an error while inspecting the container, it will be returned.
Sourcepub async fn wait_for_container_exit(&self) -> Result<ExitStatus, GenericError>
pub async fn wait_for_container_exit(&self) -> Result<ExitStatus, GenericError>
Waits for the container to finish successfully.
The container’s exit status is returned, indicating success (exit code 0) or failure (exit code != 0), including any error message related to the failure.
§Errors
If an error is encountered while waiting for the container to exit, it will be returned.