From 08b2e2f1b164027b104ba3bb0f0eecb5ac34195b Mon Sep 17 00:00:00 2001 From: Hubert Deng Date: Wed, 18 Dec 2024 01:32:18 -0800 Subject: [PATCH] go back to getting matching containers by name --- devservices/utils/docker.py | 5 +++-- tests/utils/test_docker.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/devservices/utils/docker.py b/devservices/utils/docker.py index 8d854b8..e6ef6bc 100644 --- a/devservices/utils/docker.py +++ b/devservices/utils/docker.py @@ -78,7 +78,7 @@ def wait_for_healthy(container_name: str, status: Status) -> None: def get_matching_containers(label: str) -> list[str]: """ - Returns a list of container IDs with the given label + Returns a list of container names with the given label """ check_docker_daemon_running() try: @@ -87,7 +87,8 @@ def get_matching_containers(label: str) -> list[str]: [ "docker", "ps", - "-q", + "--format", + "{{.Names}}", "--filter", f"label={label}", ], diff --git a/tests/utils/test_docker.py b/tests/utils/test_docker.py index efde2e1..c4110c9 100644 --- a/tests/utils/test_docker.py +++ b/tests/utils/test_docker.py @@ -53,7 +53,8 @@ def test_get_matching_containers( [ "docker", "ps", - "-q", + "--format", + "{{.Names}}", "--filter", f"label={DEVSERVICES_ORCHESTRATOR_LABEL}", ], @@ -90,7 +91,8 @@ def test_get_matching_containers_error( [ "docker", "ps", - "-q", + "--format", + "{{.Names}}", "--filter", f"label={DEVSERVICES_ORCHESTRATOR_LABEL}", ],