Skip to content

Instantly share code, notes, and snippets.

@jaraco
Created February 9, 2018 16:34
Show Gist options
  • Save jaraco/df5976d84de6368877e89457f5ef38fa to your computer and use it in GitHub Desktop.
Save jaraco/df5976d84de6368877e89457f5ef38fa to your computer and use it in GitHub Desktop.
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