File: prune-image.rs

package info (click to toggle)
rust-dockworker 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 764 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use dockworker::{container::ContainerFilters, Docker};

#[tokio::main]
async fn main() {
    let docker = Docker::connect_with_defaults().unwrap();

    let prunedt = docker.prune_image(true).await.unwrap();
    println!("pruned(true): {prunedt:?}");

    let prunedf = docker.prune_image(false).await.unwrap();
    println!("pruned(false): {prunedf:?}");

    let containers = docker
        .list_containers(Some(true), None, None, ContainerFilters::new())
        .await
        .unwrap();

    containers.iter().for_each(|c| {
        println!("image: {}", c.Image);
    });
}