FIX: localstack is running inside the docker config flag
diff --git a/localstack/config.py b/localstack/config.py
index ba5f00842cfb1..b8ae3a032b786 100644
--- a/localstack/config.py
+++ b/localstack/config.py
@@ -245,11 +245,28 @@ def ping(host):
 
 
 def in_docker():
-    """ Returns True if running in a docker container, else False """
+    """
+    Returns True if running in a docker container, else False
+    Ref. https://docs.docker.com/config/containers/runmetrics/#control-groups
+    """
     if not os.path.exists('/proc/1/cgroup'):
         return False
+    try:
+        if any([
+            os.path.exists('/sys/fs/cgroup/memory/docker/'),
+            any(['docker-' in file_names for file_names in os.listdir('/sys/fs/cgroup/memory/system.slice')]),
+            os.path.exists('/sys/fs/cgroup/docker/'),
+            any(['docker-' in file_names for file_names in os.listdir('/sys/fs/cgroup/system.slice/')]),
+        ]):
+            return False
+    except Exception:
+        pass
     with open('/proc/1/cgroup', 'rt') as ifh:
-        return 'docker' in ifh.read()
+        os_hostname = open('/etc/hostname', 'rt').read().strip()
+        content = ifh.read()
+        if os_hostname in content or 'docker' in content:
+            return True
+    return False
 
 
 is_in_docker = in_docker()

Added mechanism to check whether localstack instance is running inside the docker or on the host. It also will support cgroup v2.

Fix for #3675 