from pathlib import Path


def is_container() -> bool:
    """Returns `True` if process is running inside a (Docker) container."""
    cgroup_path = Path("/proc/self/cgroup")
    return (
        Path("/.dockerenv").exists()
        or cgroup_path.is_file()
        and any("docker" in line for line in cgroup_path.open(mode="r"))
    )