From 6b5b1a31e2293ce5b6bf3fafe45d356900adc00e Mon Sep 17 00:00:00 2001 From: jlusiardi Date: Sat, 18 Dec 2021 21:33:01 +0000 Subject: [PATCH 1/2] remove dependency to /proc/self/cgroup /proc/self/cgroup does not contain the required information anymore --- nginx_proxy.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/nginx_proxy.py b/nginx_proxy.py index adb2939..6e19971 100755 --- a/nginx_proxy.py +++ b/nginx_proxy.py @@ -172,22 +172,9 @@ def get_pid(): def get_docker_id(): - """This function extracts the container's id from /proc/self/cgroup.""" - id = '' - with open('/proc/self/cgroup', 'r') as file: - 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 + """This function extracts the container's id from /etc/hostname.""" + with open('/etc/hostname', 'r') as file: + return file.read().strip() def get_listen_ips(): -- 2.30.2 From 753ef6b87e4ee78f8a8afcf709e3bc6be8bfabac Mon Sep 17 00:00:00 2001 From: jlusiardi Date: Sat, 18 Dec 2021 21:35:29 +0000 Subject: [PATCH 2/2] update documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cc758a8..8f607ef 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ Since the container uses Docker's internal event reporting, it needs access to t moment, only access via UNIX socket is possible. Because of that, the socket has to be handed into the container (*-v /var/run/docker.sock:/var/run/docker.sock*). +**Note: do not change hostname for container, since the code relies on the hostname to be +the short id!** + ### Single IP / All IPs This option is used if your Docker Host has only one IP or if there is no need to differentiate between different IPs regarding wether a Web App is available on it. -- 2.30.2