pub trait ContainerManager {
Show 14 methods
// Required methods
fn docker(&self) -> &Arc<Docker>;
fn docker_credentials(&self) -> &DockerCredentials;
fn docker_default_config(&self) -> &Config<String>;
// Provided methods
fn get_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ContainerResult<Version>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn get_container_config(
&self,
image_name: &str,
env: Option<Vec<String>>,
overrides: DockerContainerOverrides,
) -> Config<String> { ... }
fn get_image_size<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
image: &'life1 str,
tag: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = ContainerResult<u64>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn load_image_from_archive<'life0, 'life1, 'async_trait>(
&'life0 self,
filepath: &'life1 str,
quiet: bool,
) -> Pin<Box<dyn Future<Output = ContainerResult<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn fetch_image<'life0, 'life1, 'async_trait>(
&'life0 self,
image_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = ContainerResult<bool>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn inspect_image<'life0, 'life1, 'async_trait>(
&'life0 self,
image_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = ContainerResult<ImageInspect>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn create_docker_container<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
image_name: &'life2 str,
env: Option<Vec<String>>,
overrides: Option<DockerContainerOverrides>,
) -> Pin<Box<dyn Future<Output = ContainerResult<DockerContainer>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn prune_container<'life0, 'async_trait>(
&'life0 self,
id: String,
) -> Pin<Box<dyn Future<Output = ContainerResult<String>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn prune_containers<'life0, 'life1, 'async_trait>(
&'life0 self,
until: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn prune_images<'life0, 'life1, 'async_trait>(
&'life0 self,
until: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_active_containers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ContainerResult<Vec<ContainerSummary>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
This ContainerManager trait provides utilities for managing a set of docker containers. It includes functions for creating, starting, stopping, and removing containers, as well as querying their status and retrieving their logs.
§Examples
use switchboard_container_utils::manager::{ContainerManager, DockerManager};
use bollard::Docker;
let manager = Arc::new(DockerManager::new(
Arc::new(Docker::connect_with_unix_defaults().unwrap()),
Some(Config {
..get_default_docker_config()
}),
));
Required Methods§
fn docker(&self) -> &Arc<Docker>
fn docker_credentials(&self) -> &DockerCredentials
fn docker_default_config(&self) -> &Config<String>
Provided Methods§
Sourcefn get_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ContainerResult<Version>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ContainerResult<Version>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_container_config( &self, image_name: &str, env: Option<Vec<String>>, overrides: DockerContainerOverrides, ) -> Config<String>
fn get_image_size<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
image: &'life1 str,
tag: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = ContainerResult<u64>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn load_image_from_archive<'life0, 'life1, 'async_trait>(
&'life0 self,
filepath: &'life1 str,
quiet: bool,
) -> Pin<Box<dyn Future<Output = ContainerResult<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_image_from_archive<'life0, 'life1, 'async_trait>(
&'life0 self,
filepath: &'life1 str,
quiet: bool,
) -> Pin<Box<dyn Future<Output = ContainerResult<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Examples found in repository?
examples/simple.rs (line 16)
7async fn main() {
8 let container_manager = DockerManager::new(
9 Arc::new(Docker::connect_with_unix_defaults().unwrap()),
10 Some(Config {
11 ..get_default_docker_config()
12 }),
13 );
14
15 container_manager
16 .load_image_from_archive("../../apps/function-manager/files/qvn.tar", false)
17 .await
18 .unwrap();
19}