def get_docker_socket() -> str:
    """
    Determine the docker socket, prefer value given by env variable

    Using the docker api ensure we handle rootless docker properly
    """
    if socket_path := environ.get("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE"):
        return socket_path

    client = docker.from_env()
    try:
        socket_path = client.api.get_adapter(client.api.base_url).socket_path
        # return the normalized path as string
        return str(Path(socket_path).absolute())
    except AttributeError:
        return "/var/run/docker.sock"

    Determine the docker socket, prefer value given by env variable

    Using the docker api ensure we handle rootless docker properly
    
core/testcontainers/core/config.py