Created
January 22, 2020 04:16
-
-
Save cbitterfield/2fca92d19517d3466cffffc17f778060 to your computer and use it in GitHub Desktop.
Find out if the python program is running in a docker container
This file contains 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
#!/usr/bin/env python3 | |
def runningInDocker(): | |
with open('/proc/self/cgroup', 'r') as procfile: | |
for line in procfile: | |
fields = line.strip().split('/') | |
if 'docker' in fields: | |
return True | |
return False | |
print(runningInDocker()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment