Skip to main content

lab_ops_lab_lib/
docker.rs

1//! Docker client helpers used by both natmap and auto-discover.
2
3use bollard::Docker;
4use color_eyre::eyre::Result;
5
6/// Connect to the local Docker daemon via the default socket or `DOCKER_HOST` env var.
7pub fn connect() -> Result<Docker> {
8    Ok(Docker::connect_with_local_defaults()?)
9}
10
11/// Strip the leading `/` that Docker prepends to container names.
12///
13/// Docker names come in the format `"/example-drive"`. This returns `"example-drive"`.
14pub fn trim_container_name(name: &str) -> &str {
15    name.trim_start_matches('/')
16}