Skip to content

container

is_docker_socket_mounted(docker_socket_path)

Check if the given path is a mounted Docker socket.

Parameters:

Name Type Description Default
docker_socket_path str

The path to the socket file.

required

Returns:

Name Type Description
bool bool

True if the path is a Unix socket, False otherwise.

Source code in inference/core/utils/container.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def is_docker_socket_mounted(docker_socket_path: str) -> bool:
    """
    Check if the given path is a mounted Docker socket.

    Args:
        docker_socket_path (str): The path to the socket file.

    Returns:
        bool: True if the path is a Unix socket, False otherwise.
    """
    if os.path.exists(docker_socket_path):
        socket_stat = os.stat(docker_socket_path)
        if stat.S_ISSOCK(socket_stat.st_mode):
            return True
    return False