Try to connect to a local container engine (Docker or Podman). Tries Docker first (`connect_with_local_defaults`, which respects `DOCKER_HOST`). If Docker is unavailable, falls back to the Podman socket, which exposes a Docker-compatible API.
()
| 3264 | /// `DOCKER_HOST`). If Docker is unavailable, falls back to the Podman |
| 3265 | /// socket, which exposes a Docker-compatible API. |
| 3266 | async fn connect_local_container_engine() -> Option<Docker> { |
| 3267 | if let Ok(docker) = Docker::connect_with_local_defaults() |
| 3268 | && docker.ping().await.is_ok() |
| 3269 | { |
| 3270 | return Some(docker); |
| 3271 | } |
| 3272 | |
| 3273 | let podman_socket = podman_socket_path(); |
| 3274 | if podman_socket.exists() |
| 3275 | && let Ok(docker) = |
| 3276 | Docker::connect_with_unix(podman_socket.to_str()?, 120, bollard::API_DEFAULT_VERSION) |
| 3277 | && docker.ping().await.is_ok() |
| 3278 | { |
| 3279 | info!( |
| 3280 | socket = %podman_socket.display(), |
| 3281 | "vm driver: connected to Podman (Docker-compatible API)" |
| 3282 | ); |
| 3283 | return Some(docker); |
| 3284 | } |
| 3285 | |
| 3286 | None |
| 3287 | } |
| 3288 | |
| 3289 | /// Podman user socket path for the current platform. |
| 3290 | fn podman_socket_path() -> PathBuf { |
no test coverage detected