fix(agent): Add check for Linux container support to `is_docker_available`

pull/7016/head^2
Reinier van der Leer 2024-03-20 21:37:56 +01:00
parent 632686cfa5
commit bca50310f6
No known key found for this signature in database
GPG Key ID: CDC1180FDAE06193
1 changed files with 5 additions and 4 deletions

View File

@ -44,14 +44,15 @@ def we_are_running_in_a_docker_container() -> bool:
def is_docker_available() -> bool:
"""Check if Docker is available
"""Check if Docker is available and supports Linux containers
Returns:
bool: True if Docker is available, False otherwise"""
bool: True if Docker is available and supports Linux containers, False otherwise
"""
try:
client = docker.from_env()
client.ping()
return True
docker_info = client.info()
return docker_info["OSType"] == "linux"
except Exception:
return False