Created
February 9, 2018 16:34
-
-
Save jaraco/df5976d84de6368877e89457f5ef38fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_docker(): | |
path = f'/proc/{os.getpid()}/cgroup' | |
pattern = re.compile(r'\d+:\w+:/docker/\w+') | |
return os.path.isfile(path) and any(map(pattern.match, open(path))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment