[docs]defin_container()->bool:"""Check if the current process is running in a container. Returns ------- bool Whether or not the current process is running in a container. """try:proc_1=r"/proc/1/sched"out=pathlib.Path(proc_1).read_text()ifos.path.exists(proc_1)else""checks=["docker"inout,"/lxc/"inout,out.split(" ")[0]notin("systemd","init",)ifoutelseFalse,os.path.exists("./dockerenv"),os.path.exists("/.dockerinit"),os.getenv("container")isnotNone,]returnany(checks)exceptException:returnFalse