()
| 206 | } |
| 207 | |
| 208 | fn docker_socket_candidates() -> Vec<PathBuf> { |
| 209 | let mut candidates = Vec::new(); |
| 210 | |
| 211 | if let Ok(host) = std::env::var("DOCKER_HOST") |
| 212 | && let Some(path) = docker_host_unix_socket_path(&host) |
| 213 | { |
| 214 | candidates.push(path); |
| 215 | } |
| 216 | |
| 217 | candidates.push(PathBuf::from("/var/run/docker.sock")); |
| 218 | |
| 219 | if let Some(home) = std::env::var_os("HOME") { |
| 220 | candidates.push(PathBuf::from(home).join(".docker/run/docker.sock")); |
| 221 | } |
| 222 | |
| 223 | if let Some(runtime_dir) = std::env::var_os("XDG_RUNTIME_DIR") { |
| 224 | candidates.push(PathBuf::from(runtime_dir).join("docker.sock")); |
| 225 | } |
| 226 | |
| 227 | candidates |
| 228 | } |
| 229 | |
| 230 | fn docker_host_unix_socket_path(host: &str) -> Option<PathBuf> { |
| 231 | let path = host.trim().strip_prefix("unix://")?; |
no test coverage detected