- move is_docker_rootless method from tutor to tutor-discovery - move is_docker_rootless related tests from tutor to tutor-discovery and modify makefile according to it.
17 lines
470 B
Python
17 lines
470 B
Python
import subprocess
|
|
from functools import lru_cache
|
|
|
|
|
|
@lru_cache(maxsize=None)
|
|
def is_docker_rootless() -> bool:
|
|
"""
|
|
A helper function to determine if Docker is running in rootless mode.
|
|
|
|
- https://docs.docker.com/engine/security/rootless/
|
|
"""
|
|
try:
|
|
results = subprocess.run(["docker", "info"], capture_output=True, check=True)
|
|
return "rootless" in results.stdout.decode()
|
|
except subprocess.CalledProcessError:
|
|
return False
|