MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / list_containers

Function list_containers

guest-agent/src/guest_api_service.rs:119–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119pub(crate) async fn list_containers() -> Result<ListContainersResponse> {
120 let docker = Docker::connect_with_defaults().context("Failed to connect to Docker")?;
121 let containers = docker
122 .list_containers::<&str>(Some(ListContainersOptions {
123 all: true,
124 ..Default::default()
125 }))
126 .await
127 .context("Failed to list containers")?;
128 Ok(ListContainersResponse {
129 containers: containers
130 .into_iter()
131 .map(|c| Container {
132 id: c.id.unwrap_or_default(),
133 names: c.names.unwrap_or_default(),
134 image: c.image.unwrap_or_default(),
135 image_id: c.image_id.unwrap_or_default(),
136 created: c.created.unwrap_or_default(),
137 state: c.state.unwrap_or_default(),
138 status: c.status.unwrap_or_default(),
139 })
140 .collect(),
141 })
142}
143
144fn get_interfaces() -> Vec<Interface> {
145 sysinfo::Networks::new_with_refreshed_list()

Callers 2

list_containersMethod · 0.85
indexFunction · 0.85

Calls 1

into_iterMethod · 0.80

Tested by

no test coverage detected