def _major_version_from_image_name(image_name: str) -> int:
    """Returns the major version from a container name like 'elasticsearch:8.1.0'
    If the major version could not be determined, it will use the most recent
    one (8 at the time of writing 2022-08-11).
    """
    version_string = image_name.split(":")[-1]
    regex_match = re.compile(r"(\d+)\.\d+\.\d+").match(version_string)
    if not regex_match:
        logging.warning(
            "Could not determine major version from image name '%s'. Will use %s", image_name, _FALLBACK_VERSION
        )
        return _FALLBACK_VERSION
    else:
        return int(regex_match.group(1))
Returns the major version from a container name like 'elasticsearch:8.1.0'
    If the major version could not be determined, it will use the most recent
    one (8 at the time of writing 2022-08-11).
    
modules/elasticsearch/testcontainers/elasticsearch/__init__.py