remove dependency to /proc/self/cgroup
/proc/self/cgroup does not contain the required information anymore
This commit is contained in:
parent
0164866a8d
commit
6b5b1a31e2
@ -172,22 +172,9 @@ def get_pid():
|
|||||||
|
|
||||||
|
|
||||||
def get_docker_id():
|
def get_docker_id():
|
||||||
"""This function extracts the container's id from /proc/self/cgroup."""
|
"""This function extracts the container's id from /etc/hostname."""
|
||||||
id = ''
|
with open('/etc/hostname', 'r') as file:
|
||||||
with open('/proc/self/cgroup', 'r') as file:
|
return file.read().strip()
|
||||||
lines = file.read().split('\n')
|
|
||||||
for line in lines:
|
|
||||||
index = line.find('docker-')
|
|
||||||
if index != -1:
|
|
||||||
id = line[index+7:-6]
|
|
||||||
break
|
|
||||||
index = line.find('docker/')
|
|
||||||
if index != -1:
|
|
||||||
id = line[index+7:]
|
|
||||||
break
|
|
||||||
if id == '':
|
|
||||||
logging.error('could not determine container\'s id!')
|
|
||||||
return id
|
|
||||||
|
|
||||||
|
|
||||||
def get_listen_ips():
|
def get_listen_ips():
|
||||||
|
Loading…
Reference in New Issue
Block a user