MCPcopy Create free account
hub / github.com/FastLED/FastLED / docker_container_exists

Function docker_container_exists

ci/docker_utils/container_db.py:371–399  ·  view source on GitHub ↗

Check if a Docker container exists (by name). Args: container_name: Container name to check Returns: Container ID if exists, None otherwise

(container_name: str)

Source from the content-addressed store, hash-verified

369
370
371def docker_container_exists(container_name: str) -> Optional[str]:
372 """Check if a Docker container exists (by name).
373
374 Args:
375 container_name: Container name to check
376
377 Returns:
378 Container ID if exists, None otherwise
379 """
380 try:
381 result = subprocess.run(
382 [
383 get_docker_command(),
384 "ps",
385 "-a",
386 "--filter",
387 f"name=^{container_name}$",
388 "--format",
389 "{{.ID}}",
390 ],
391 capture_output=True,
392 text=True,
393 timeout=10,
394 )
395 if result.returncode == 0 and result.stdout.strip():
396 return result.stdout.strip()
397 return None
398 except (FileNotFoundError, subprocess.TimeoutExpired):
399 return None
400
401
402def docker_stop_container(container_id: str) -> bool:

Callers 3

run_docker_testsFunction · 0.90
_run_docker_stepFunction · 0.90
prepare_containerFunction · 0.85

Calls 2

get_docker_commandFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected