Commit 6018da3
authored
fix(core): make is_podman respect resolved docker host (#1048)
Follow-up to #1026 (auto-detect DOCKER_HOST from the current docker
context).
## Problem
`is_podman()` used a bare `docker.from_env()`, which ignores the host
resolved by `get_docker_host()` and never sets `use_ssh_client` for SSH
hosts.
When a remote daemon is configured via a docker context (and
`DOCKER_HOST` is not exported), `is_podman()` hit the local default
socket, failed, and silently returned `False`. Two consequences:
- Podman over a docker context was never detected, so Podman-specific
normalisation (e.g. in the port tests) was skipped.
- SSH-based remote daemons could not be queried at all (paramiko also
fails under pytest stdin capture, which is why `DockerClient` passes
`use_ssh_client=True`).
## Fix
`is_podman()` now resolves the host the same way `DockerClient` does: it
builds a client with the resolved `base_url` (and `use_ssh_client=True`
for `ssh://`), and only falls back to `docker.from_env()` when no host
is resolved.
## Tests
- Pinned `get_docker_host` to `None` in the existing `test_is_podman`
parametrisation so it is deterministic regardless of the docker context
configured on the machine running it (it was silently passing only when
no context was set).
- Added `test_is_podman_uses_resolved_host` covering the resolved-host
SSH branch.
## Verified manually
Ran `tests/core/test_core_ports.py` and
`tests/core/test_docker_client.py` against two remote backends over SSH:
| Context | Backend | `is_podman()` | Port tests |
| --- | --- | --- | --- |
| remote Podman | Podman 5.4 | `True` (was `False`) | 26 passed (was 10
failed) |
| remote Docker | Docker 29.4 | `False` | 26 passed |
Also simulated the Docker Desktop `desktop-linux` context from #757:
`get_docker_host()` returns the context socket and `is_podman()` queries
that same socket, returning `False` as expected.1 parent 7dee471 commit 6018da3
2 files changed
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
539 | | - | |
540 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
541 | 552 | | |
542 | 553 | | |
543 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
376 | 379 | | |
377 | 380 | | |
378 | 381 | | |
| |||
389 | 392 | | |
390 | 393 | | |
391 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
392 | 417 | | |
393 | 418 | | |
394 | 419 | | |
| |||
0 commit comments