From d7fd767c99174bd2d0398662106d2668f958d38c Mon Sep 17 00:00:00 2001
From: Zsombor Welker <fedora@zdeqb.com>
Date: Sun, 25 Apr 2021 17:56:39 +0200
Subject: [PATCH] Use an explicit prefix check

... to avoid cases where the hostname is contained within the
container_id, but is not the actual prefix.
---
 src/systemd_resolved_docker/dockerwatcher.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/systemd_resolved_docker/dockerwatcher.py b/src/systemd_resolved_docker/dockerwatcher.py
index ae9937f..aae6d15 100644
--- a/src/systemd_resolved_docker/dockerwatcher.py
+++ b/src/systemd_resolved_docker/dockerwatcher.py
@@ -51,7 +51,7 @@ class DockerWatcher(Thread):
 
             # if no explicit --hostname is provided, than it will be the first 12 characters of the container_id.
             # In that case, the hostname can be ignored
-            if hostname not in container_id:
+            if hostname != container_id[:12]:
                 if len(domain) > 0:
                     common_hostnames.append('%s.%s' % (hostname, domain))
                 else:
-- 
GitLab