{"id":501609,"date":"2026-11-04T12:39:11","date_gmt":"2026-11-04T09:39:11","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=501609"},"modified":"2026-11-04T12:39:11","modified_gmt":"2026-11-04T09:39:11","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=501609","title":{"rendered":"UFW \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u00ab\u0432\u0441\u0451 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u00bb, \u0430 Postgres \u0442\u043e\u0440\u0447\u0438\u0442 \u043d\u0430\u0440\u0443\u0436\u0443: \u043f\u0438\u0448\u0435\u043c \u0430\u0443\u0434\u0438\u0442 \u043f\u043e\u0440\u0442\u043e\u0432 \u0434\u043b\u044f docker compose \u043d\u0430 Python"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0432 \u0442\u043e\u043f\u0435 \u0441\u043d\u043e\u0432\u0430 \u0432\u0441\u043f\u043b\u044b\u043b\u0430 \u0441\u0442\u0430\u0440\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u0441\u0432\u0435\u0436\u0438\u0439 VPS, <code>ufw default deny incoming<\/code>, \u043d\u0430\u0440\u0443\u0436\u0443 \u0442\u043e\u043b\u044c\u043a\u043e 22, 80 \u0438 443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 compose-\u0444\u0430\u0439\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>ports: - \"5432:5432\"<\/code> \u2014 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435 \u043b\u0435\u0436\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u043a\u0430 \u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u043a\u043e\u0448\u0435\u043b\u044c\u043a\u043e\u043c. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. \u042f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e \u0434\u0440\u0443\u0433\u043e\u0435: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0439 compose-\u0444\u0430\u0439\u043b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0434\u043e\u0435\u0445\u0430\u043b \u0434\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u2014 \u0434\u0432\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 Python. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 compose-\u0444\u0430\u0439\u043b\u044b \u0434\u043e \u0434\u0435\u043f\u043b\u043e\u044f \u0438 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d \u043d\u0430 \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u0442, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435, \u0431\u0435\u0437 <code>ss<\/code> \u0438 <code>netstat<\/code>, \u043f\u0440\u044f\u043c\u043e \u0438\u0437 <code>\/proc<\/code>. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b \u043d\u0430 Python 3.13 \u0438 PyYAML 6.0.3, \u0432\u044b\u0432\u043e\u0434 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 UFW \u0442\u0443\u0442 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442<\/h3>\n<p>\u041a\u043e\u0440\u043e\u0442\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u043b\u043e\u0432\u0438\u043c. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Docker \u043f\u0440\u044f\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e Docker \u0438 ufw \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b: \u0442\u0440\u0430\u0444\u0438\u043a \u043a \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u0440\u0442\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>nat<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u043a <code>INPUT<\/code> \u0438 <code>OUTPUT<\/code>, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ufw. \u041f\u0440\u0430\u0432\u0438\u043b\u0430 ufw \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/f4\/c8\/ea\/f4c8eacf90e1662064c0d4d38257a436.png\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/f4\/c8\/ea\/f4c8eacf90e1662064c0d4d38257a436.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/f4\/c8\/ea\/f4c8eacf90e1662064c0d4d38257a436.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0432\u043e\u0434: \u0444\u0430\u0435\u0440\u0432\u043e\u043b \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u2014 \u043d\u0435 \u0442\u0430 \u043b\u0438\u043d\u0438\u044f \u043e\u0431\u043e\u0440\u043e\u043d\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041d\u0430\u0434\u0451\u0436\u043d\u0435\u0435 \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435 \u0432\u043e\u043e\u0431\u0449\u0435, \u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u043c, \u0432\u0435\u0448\u0430\u0442\u044c \u043d\u0430 <code>127.0.0.1<\/code> \u0438 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 SSH-\u0442\u0443\u043d\u043d\u0435\u043b\u044c.<\/p>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u0434\u0435\u0442\u0430\u043b\u044c \u0438\u0437 \u0442\u043e\u0439 \u0436\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: \u0435\u0441\u043b\u0438 \u0432 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u043f\u043e\u0440\u0442\u0430 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430, Docker \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043f\u043e\u0440\u0442 \u043d\u0430 \u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u2014 \u0438 <code>0.0.0.0<\/code>, \u0438 <code>[::]<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c <code>\"5432:5432\"<\/code> \u0438 <code>\"0.0.0.0:5432:5432\"<\/code> \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435.<\/p>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u0440\u0442\u043e\u0432<\/h3>\n<p>Compose \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u044b. \u041a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430 <code>[host_ip:][published:]target[\/protocol]<\/code>. \u0414\u043b\u0438\u043d\u043d\u0430\u044f \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 <code>target<\/code>, <code>published<\/code>, <code>host_ip<\/code>, <code>protocol<\/code>. \u041d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0442\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u044f:<\/p>\n<ul>\n<li>\n<p>\u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430 \u2014 loopback (<code>127.0.0.1<\/code>, <code>::1<\/code>). \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u0442, \u043f\u043e\u0440\u0442 \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d \u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (80, 443). \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u0442, \u0438 \u043f\u043e\u0440\u0442 \u043d\u0435 \u0438\u0437 \u0431\u0435\u043b\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043b\u043e\u0432\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\"9100\"<\/code>. \u0415\u0451 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0448\u0443\u0442, \u0434\u0443\u043c\u0430\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u043e\u0440\u0442\u00bb. \u041d\u0430 \u0434\u0435\u043b\u0435 Compose \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 9100 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0445\u043e\u0441\u0442\u0430, \u043f\u0440\u0438\u0447\u0451\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445.<\/p>\n<h3>\u0421\u043a\u0440\u0438\u043f\u0442 1: \u0430\u0443\u0434\u0438\u0442 compose-\u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<pre><code class=\"yaml\">services:  api:    image: myapp\/api:1.4    ports:      - \"80:8000\"  db:    image: postgres:17    ports:      - \"5432:5432\"  redis:    image: redis:7    ports:      - \"127.0.0.1:6379:6379\"  adminer:    image: adminer    ports:      - target: 8080        published: 8081  metrics:    image: prom\/node-exporter    ports:      - \"9100\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"python\">import sysimport yamlSAFE_HOSTS = {\"127.0.0.1\", \"::1\", \"localhost\"}ALLOWED_PUBLIC = {80, 443}def parse_short(spec: str):    \"\"\"'[host_ip:][published:]target[\/proto]' -&gt; (host_ip, published, target)\"\"\"    spec = str(spec).split(\"\/\")[0]    if spec.startswith(\"[\"):  # IPv6: [::1]:5432:5432        host, rest = spec[1:].split(\"]:\", 1)        parts = [host] + rest.split(\":\")    else:        parts = spec.split(\":\")    if len(parts) == 1:        return \"0.0.0.0\", None, parts[0]    if len(parts) == 2:        return \"0.0.0.0\", parts[0], parts[1]    return parts[0], parts[1], parts[2]def parse_long(item: dict):    return (item.get(\"host_ip\", \"0.0.0.0\"),            item.get(\"published\"),            item.get(\"target\"))def audit(path: str) -&gt; int:    with open(path, encoding=\"utf-8\") as f:        data = yaml.safe_load(f)    problems = 0    for name, svc in (data.get(\"services\") or {}).items():        for p in svc.get(\"ports\") or []:            host, published, target = (parse_long(p) if isinstance(p, dict)                                       else parse_short(p))            if host in SAFE_HOSTS:                status = \"ok    \"            elif published is None:                status = \"RANDOM\"                problems += 1            elif int(str(published).split(\"-\")[0]) in ALLOWED_PUBLIC:                status = \"public\"            else:                status = \"OPEN  \"                problems += 1            print(f\"{status} {name:&lt;8} {host}:{published or '?'} -&gt; {target}\")    return problemsif __name__ == \"__main__\":    n = audit(sys.argv[1] if len(sys.argv) &gt; 1 else \"compose.yaml\")    print(f\"\\n\u043f\u0440\u043e\u0431\u043b\u0435\u043c: {n}\")    sys.exit(1 if n else 0)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a:<\/p>\n<pre><code class=\"bash\">$ python3 compose_audit.py; echo \"exit=$?\"public api      0.0.0.0:80 -&gt; 8000OPEN   db       0.0.0.0:5432 -&gt; 5432ok     redis    127.0.0.1:6379 -&gt; 6379OPEN   adminer  0.0.0.0:8081 -&gt; 8080RANDOM metrics  0.0.0.0:? -&gt; 9100\u043f\u0440\u043e\u0431\u043b\u0435\u043c: 3exit=1<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/7c\/fa\/db\/7cfadba685ecde15c0ee3696cfcdeec8.png\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/7c\/fa\/db\/7cfadba685ecde15c0ee3696cfcdeec8.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/7c\/fa\/db\/7cfadba685ecde15c0ee3696cfcdeec8.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0422\u0440\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0437 \u043f\u044f\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0438 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0434\u043b\u044f \u00ab\u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c, \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u0430\u0432\u043b\u044e\u00bb. Redis \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a loopback, API \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0434\u043e \u0447\u0438\u043d\u0438\u0442\u044c.<\/p>\n<p>\u041d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0437\u0434\u0435\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0435\u0437 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0432\u0441\u0442\u0430\u0451\u0442 \u0432 pre-commit \u0438\u043b\u0438 \u0432 \u0448\u0430\u0433 CI \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u043f\u043b\u043e\u0435\u043c: \u0444\u0430\u0439\u043b \u0441 <code>OPEN<\/code> \u0438\u043b\u0438 <code>RANDOM<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0451\u0442.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u043f\u0430\u0440\u0441\u0435\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 IPv6, UDP \u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445:<\/p>\n<pre><code class=\"python\">from compose_audit import parse_shortfor s in [\"5432:5432\", \"127.0.0.1:6379:6379\", \"[::1]:5432:5432\",          \"9100\", \"53:53\/udp\", \"8000-8005:8000-8005\"]:    print(f\"{s!r:&lt;26} -&gt; {parse_short(s)}\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code>'5432:5432'                -&gt; ('0.0.0.0', '5432', '5432')'127.0.0.1:6379:6379'      -&gt; ('127.0.0.1', '6379', '6379')'[::1]:5432:5432'          -&gt; ('::1', '5432', '5432')'9100'                     -&gt; ('0.0.0.0', None, '9100')'53:53\/udp'                -&gt; ('0.0.0.0', '53', '53')'8000-8005:8000-8005'      -&gt; ('0.0.0.0', '8000-8005', '8000-8005')<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f: \u0434\u043b\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u00ab\u0442\u043e\u0440\u0447\u0438\u0442 \u043b\u0438 \u043d\u0430\u0440\u0443\u0436\u0443\u00bb \u043e\u043d \u043d\u0435 \u0432\u0430\u0436\u0435\u043d. \u0414\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443 \u2014 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0438\u0442\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043a\u0430\u0436\u0434\u044b\u0439. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432\u0438\u0434\u0430 <code>${DB_PORT}<\/code> \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442; \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c, \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0430\u0443\u0434\u0438\u0442 \u043f\u043e \u0432\u044b\u0432\u043e\u0434\u0443 <code>docker compose config<\/code>, \u0433\u0434\u0435 \u0432\u0441\u0451 \u0443\u0436\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u043e.<\/p>\n<\/div>\n<\/details>\n<h3>\u0421\u043a\u0440\u0438\u043f\u0442 2: \u0447\u0442\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435<\/h3>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043b\u043e\u0432\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445, \u043d\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <code>docker run -p<\/code>, \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0440\u0435\u0448\u0438\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c <code>0.0.0.0<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u2014 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0436\u0438\u0432\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c <code>ss -tlnp<\/code>, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0447\u0443\u0436\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u042f\u0434\u0440\u043e \u0438 \u0442\u0430\u043a \u043e\u0442\u0434\u0430\u0451\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0432 <code>\/proc\/net\/tcp<\/code> \u0438 <code>\/proc\/net\/tcp6<\/code>: \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <code>0A<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 LISTEN.<\/p>\n<pre><code class=\"python\">import ipaddressimport socketimport structdef hex_to_ip(h: str) -&gt; str:    if len(h) == 8:  # IPv4, little-endian        return socket.inet_ntoa(struct.pack(\"&lt;I\", int(h, 16)))    # IPv6: \u0447\u0435\u0442\u044b\u0440\u0435 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430, \u043a\u0430\u0436\u0434\u043e\u0435 little-endian    raw = b\"\".join(struct.pack(\"&lt;I\", int(h[i:i + 8], 16)) for i in range(0, 32, 8))    return str(ipaddress.IPv6Address(raw))def listeners():    for path in (\"\/proc\/net\/tcp\", \"\/proc\/net\/tcp6\"):        with open(path) as f:            next(f)            for line in f:                cols = line.split()                if cols[3] != \"0A\":  # 0A = TCP_LISTEN                    continue                ip_hex, port_hex = cols[1].split(\":\")                yield hex_to_ip(ip_hex), int(port_hex, 16)if __name__ == \"__main__\":    for ip, port in sorted(set(listeners()), key=lambda x: x[1]):        addr = ipaddress.ip_address(ip)        scope = \"\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\" if addr.is_loopback else \"\u0421\u041d\u0410\u0420\u0423\u0416\u0418\"        print(f\"{scope:&lt;9} {ip}:{port}\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u043e\u0434\u043d\u044f\u043b \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u2014 \u043e\u0434\u0438\u043d \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445, \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 loopback:<\/p>\n<pre><code class=\"bash\">$ python3 -m http.server 18080 --bind 0.0.0.0 &gt;\/dev\/null 2&gt;&amp;1 &amp;$ python3 -m http.server 18081 --bind 127.0.0.1 &gt;\/dev\/null 2&gt;&amp;1 &amp;$ python3 listeners.py | grep 1808\u0421\u041d\u0410\u0420\u0423\u0416\u0418   0.0.0.0:18080\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e  127.0.0.1:18081<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 Docker \u0432\u043a\u043b\u044e\u0447\u0451\u043d userland-proxy (<code>--userland-proxy=true<\/code>), \u0438 \u0434\u043b\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <code>docker-proxy<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0442 \u043f\u043e\u0440\u0442 \u0441\u043b\u0443\u0448\u0430\u0435\u0442. \u0422\u0430\u043a \u0447\u0442\u043e <code>0.0.0.0:5432<\/code> \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0415\u0441\u043b\u0438 userland-proxy \u0443 \u0432\u0430\u0441 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, \u0441\u043e\u043a\u0435\u0442\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0430 NAT-\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u2014 \u0442\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 <code>docker ps<\/code> \u0438\u043b\u0438 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \/proc \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u00ab\u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0451\u0434\u00bb<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0410\u0434\u0440\u0435\u0441 IPv4 \u0432 <code>\/proc\/net\/tcp<\/code> \u2014 \u044d\u0442\u043e 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0431\u0430\u0439\u0442\u043e\u0432 \u0445\u043e\u0441\u0442\u0430, \u0430 \u043d\u0430 x86 \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 ARM-\u043c\u0430\u0448\u0438\u043d \u044d\u0442\u043e little-endian. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <code>127.0.0.1<\/code> \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u043a\u0430\u043a <code>0100007F<\/code>. \u041e\u0442\u0441\u044e\u0434\u0430 <code>struct.pack(\"&lt;I\", ...)<\/code> \u043f\u0435\u0440\u0435\u0434 <code>inet_ntoa<\/code>. \u0421 IPv6 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441 \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430, \u0438 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u043d\u0435 \u0432\u0441\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u041f\u043e\u0440\u0442, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c, \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 <code>int(..., 16)<\/code>.<\/p>\n<\/div>\n<\/details>\n<h3>\u041a\u0430\u043a \u0447\u0438\u043d\u0438\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435<\/h3>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0430\u0445\u043e\u0434\u043a\u0438 \u0440\u0435\u0446\u0435\u043f\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439.<\/p>\n<p><strong>OPEN (\u0431\u0430\u0437\u0430, \u0430\u0434\u043c\u0438\u043d\u043a\u0430, \u0431\u0440\u043e\u043a\u0435\u0440).<\/strong> \u041f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043a loopback: <code>\"127.0.0.1:5432:5432\"<\/code>. \u0421 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0430 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0442\u0443\u043d\u043d\u0435\u043b\u044c: <code>ssh -L 5432:127.0.0.1:5432 user@server<\/code>, \u0430 DBeaver \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a <code>localhost:5432<\/code>. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0441\u0435\u043a\u0446\u0438\u044f <code>ports<\/code> \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0432\u0441\u0435: \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 compose-\u0441\u0435\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432\u0438\u0434\u044f\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p><strong>RANDOM.<\/strong> \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u00ab\u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c\u00bb \u043f\u043e\u0440\u0442. \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u2014 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443. \u0415\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u0441\u043d\u0430\u0440\u0443\u0436\u0438, \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0435\u0433\u043e \u044f\u0432\u043d\u043e \u0438 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c.<\/p>\n<p><strong>\u041f\u043e\u0434\u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0435\u043c\u043e\u043d\u0430.<\/strong> \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0440\u0442\u043e\u0432 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 bridge-\u0441\u0435\u0442\u044f\u0445 (\u0430 compose \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0445). \u0412 <code>\/etc\/docker\/daemon.json<\/code>:<\/p>\n<pre><code class=\"json\">{  \"default-network-opts\": {    \"bridge\": {      \"com.docker.network.bridge.host_binding_ipv4\": \"127.0.0.1\"    }  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 <code>\"5432:5432\"<\/code> \u0431\u0435\u0437 \u0430\u0434\u0440\u0435\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e loopback, \u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u044b \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\"0.0.0.0:443:443\"<\/code>. \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430 Swarm-\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u044d\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442: \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e\u0442\u0441\u044f \u043d\u0430 <code>0.0.0.0<\/code>. \u0418 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0436\u0435: \u0432 \u0440\u0435\u043b\u0438\u0437\u0430\u0445 Docker \u0441\u0442\u0430\u0440\u0448\u0435 28.0.0 \u0434\u0430\u0436\u0435 \u043f\u043e\u0440\u0442 \u043d\u0430 <code>127.0.0.1<\/code> \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0445\u043e\u0441\u0442\u0430\u043c \u0438\u0437 \u0442\u043e\u0433\u043e \u0436\u0435 L2-\u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u0430\u0440\u044b\u0439 Docker, \u044d\u0442\u043e \u043f\u043e\u0432\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/42\/4b\/8f\/424b8f1a8b98991d04dd9c7f0ecd1775.png\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/42\/4b\/8f\/424b8f1a8b98991d04dd9c7f0ecd1775.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/42\/4b\/8f\/424b8f1a8b98991d04dd9c7f0ecd1775.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u041a\u0443\u0434\u0430 \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c<\/h3>\n<p>\u0423 \u043c\u0435\u043d\u044f \u043e\u0431\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0436\u0438\u0432\u0443\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439. <code>compose_audit.py<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 CI \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 compose-\u0444\u0430\u0439\u043b, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 <code>docker compose config<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 override-\u0444\u0430\u0439\u043b\u044b \u0431\u044b\u043b\u0438 \u0443\u0436\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b. <code>listeners.py<\/code> \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e cron \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0438 \u0448\u043b\u0451\u0442 \u0432\u044b\u0432\u043e\u0434, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0451\u043c \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 <code>\u0421\u041d\u0410\u0420\u0423\u0416\u0418<\/code> \u0441 \u043f\u043e\u0440\u0442\u043e\u043c \u043d\u0435 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0445.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u0440\u0442\u043e\u0432 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u2014 \u043e\u043d\u043e \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u0431\u043e\u0442\u0430. \u041d\u043e \u043e\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0447\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u00bb, \u0430 \u0430\u0443\u0434\u0438\u0442 compose-\u0444\u0430\u0439\u043b\u0430 \u2014 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0447\u0442\u043e \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u043a\u0440\u043e\u0435\u043c\u00bb. \u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1103458\/\">https:\/\/habr.com\/ru\/articles\/1103458\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0432 \u0442\u043e\u043f\u0435 \u0441\u043d\u043e\u0432\u0430 \u0432\u0441\u043f\u043b\u044b\u043b\u0430 \u0441\u0442\u0430\u0440\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u0441\u0432\u0435\u0436\u0438\u0439 VPS, ufw default deny incoming, \u043d\u0430\u0440\u0443\u0436\u0443 \u0442\u043e\u043b\u044c\u043a\u043e 22, 80 \u0438 443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 compose-\u0444\u0430\u0439\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f ports: &#8212; &#171;5432:5432&#187; \u2014 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435 \u043b\u0435\u0436\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u043a\u0430 \u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u043a\u043e\u0448\u0435\u043b\u044c\u043a\u043e\u043c. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. \u042f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e \u0434\u0440\u0443\u0433\u043e\u0435: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0439 compose-\u0444\u0430\u0439\u043b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0434\u043e\u0435\u0445\u0430\u043b \u0434\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.\u041d\u0438\u0436\u0435 \u2014 \u0434\u0432\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 Python. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 compose-\u0444\u0430\u0439\u043b\u044b \u0434\u043e \u0434\u0435\u043f\u043b\u043e\u044f \u0438 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d \u043d\u0430 \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u0442, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435, \u0431\u0435\u0437 ss \u0438 netstat, \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \/proc. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b \u043d\u0430 Python 3.13 \u0438 PyYAML 6.0.3, \u0432\u044b\u0432\u043e\u0434 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439.\u041f\u043e\u0447\u0435\u043c\u0443 UFW \u0442\u0443\u0442 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442\u041a\u043e\u0440\u043e\u0442\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u043b\u043e\u0432\u0438\u043c. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Docker \u043f\u0440\u044f\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e Docker \u0438 ufw \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b: \u0442\u0440\u0430\u0444\u0438\u043a \u043a \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u0440\u0442\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 nat, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u043a INPUT \u0438 OUTPUT, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ufw. \u041f\u0440\u0430\u0432\u0438\u043b\u0430 ufw \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f.\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0432\u043e\u0434: \u0444\u0430\u0435\u0440\u0432\u043e\u043b \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u2014 \u043d\u0435 \u0442\u0430 \u043b\u0438\u043d\u0438\u044f \u043e\u0431\u043e\u0440\u043e\u043d\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041d\u0430\u0434\u0451\u0436\u043d\u0435\u0435 \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435 \u0432\u043e\u043e\u0431\u0449\u0435, \u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u043c, \u0432\u0435\u0448\u0430\u0442\u044c \u043d\u0430 127.0.0.1 \u0438 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 SSH-\u0442\u0443\u043d\u043d\u0435\u043b\u044c.\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u0434\u0435\u0442\u0430\u043b\u044c \u0438\u0437 \u0442\u043e\u0439 \u0436\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: \u0435\u0441\u043b\u0438 \u0432 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u043f\u043e\u0440\u0442\u0430 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430, Docker \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043f\u043e\u0440\u0442 \u043d\u0430 \u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u2014 \u0438 0.0.0.0, \u0438 [::]. \u0422\u043e \u0435\u0441\u0442\u044c &#171;5432:5432&#187; \u0438 &#171;0.0.0.0:5432:5432&#187; \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435.\u041a\u0430\u043a\u0438\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u0440\u0442\u043e\u0432Compose \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u044b. \u041a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430 [host_ip:][published:]target[\/protocol]. \u0414\u043b\u0438\u043d\u043d\u0430\u044f \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 target, published, host_ip, protocol. \u041d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0442\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u044f:\u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430 \u2014 loopback (127.0.0.1, ::1). \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e;\u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u0442, \u043f\u043e\u0440\u0442 \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d \u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (80, 443). \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435;\u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u0442, \u0438 \u043f\u043e\u0440\u0442 \u043d\u0435 \u0438\u0437 \u0431\u0435\u043b\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043b\u043e\u0432\u0438\u0442\u044c.\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#171;9100&#187;. \u0415\u0451 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0448\u0443\u0442, \u0434\u0443\u043c\u0430\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u043e\u0440\u0442\u00bb. \u041d\u0430 \u0434\u0435\u043b\u0435 Compose \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 9100 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0445\u043e\u0441\u0442\u0430, \u043f\u0440\u0438\u0447\u0451\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445.\u0421\u043a\u0440\u0438\u043f\u0442 1: \u0430\u0443\u0434\u0438\u0442 compose-\u0444\u0430\u0439\u043b\u0430\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:services:  api:    image: myapp\/api:1.4    ports:      &#8212; &#171;80:8000&#187;  db:    image: postgres:17    ports:      &#8212; &#171;5432:5432&#187;  redis:    image: redis:7    ports:      &#8212; &#171;127.0.0.1:6379:6379&#187;  adminer:    image: adminer    ports:      &#8212; target: 8080        published: 8081  metrics:    image: prom\/node-exporter    ports:      &#8212; &#171;9100&#187;\u0421\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442:import sysimport yamlSAFE_HOSTS = {&#171;127.0.0.1&#187;, &#171;::1&#187;, &#171;localhost&#187;}ALLOWED_PUBLIC = {80, 443}def parse_short(spec: str):    &#171;&#187;&#187;&#8216;[host_ip:][published:]target[\/proto]&#8217; -&gt; (host_ip, published, target)&#187;&#187;&#187;    spec = str(spec).split(&#171;\/&#187;)[0]    if spec.startswith(&#171;[&#171;):  # IPv6: [::1]:5432:5432        host, rest = spec[1:].split(&#171;]:&#187;, 1)        parts = [host] + rest.split(&#171;:&#187;)    else:        parts = spec.split(&#171;:&#187;)    if len(parts) == 1:        return &#171;0.0.0.0&#187;, None, parts[0]    if len(parts) == 2:        return &#171;0.0.0.0&#187;, parts[0], parts[1]    return parts[0], parts[1], parts[2]def parse_long(item: dict):    return (item.get(&#171;host_ip&#187;, &#171;0.0.0.0&#187;),            item.get(&#171;published&#187;),            item.get(&#171;target&#187;))def audit(path: str) -&gt; int:    with open(path, encoding=&#187;utf-8&#8243;) as f:        data = yaml.safe_load(f)    problems = 0    for name, svc in (data.get(&#171;services&#187;) or {}).items():        for p in svc.get(&#171;ports&#187;) or []:            host, published, target = (parse_long(p) if isinstance(p, dict)                                       else parse_short(p))            if host in SAFE_HOSTS:                status = &#171;ok    &#187;            elif published is None:                status = &#171;RANDOM&#187;                problems += 1            elif int(str(published).split(&#171;-&#171;)[0]) in ALLOWED_PUBLIC:                status = &#171;public&#187;            else:                status = &#171;OPEN  &#187;                problems += 1            print(f&#187;{status} {name:&lt;8} {host}:{published or &#8216;?&#8217;} -&gt; {target}&#187;)    return problemsif __name__ == &#171;__main__&#187;:    n = audit(sys.argv[1] if len(sys.argv) &gt; 1 else &#171;compose.yaml&#187;)    print(f&#187;\\n\u043f\u0440\u043e\u0431\u043b\u0435\u043c: {n}&#187;)    sys.exit(1 if n else 0)\u0417\u0430\u043f\u0443\u0441\u043a:$ python3 compose_audit.py; echo &#171;exit=$?&#187;public api      0.0.0.0:80 -&gt; 8000OPEN   db       0.0.0.0:5432 -&gt; 5432ok     redis    127.0.0.1:6379 -&gt; 6379OPEN   adminer  0.0.0.0:8081 -&gt; 8080RANDOM metrics  0.0.0.0:? -&gt; 9100\u043f\u0440\u043e\u0431\u043b\u0435\u043c: 3exit=1\u0422\u0440\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0437 \u043f\u044f\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0438 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0434\u043b\u044f \u00ab\u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c, \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u0430\u0432\u043b\u044e\u00bb. Redis \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a loopback, API \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0434\u043e \u0447\u0438\u043d\u0438\u0442\u044c.\u041d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0437\u0434\u0435\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0435\u0437 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0432\u0441\u0442\u0430\u0451\u0442 \u0432 pre-commit \u0438\u043b\u0438 \u0432 \u0448\u0430\u0433 CI \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u043f\u043b\u043e\u0435\u043c: \u0444\u0430\u0439\u043b \u0441 OPEN \u0438\u043b\u0438 RANDOM \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0451\u0442.\u041a\u0430\u043a \u043f\u0430\u0440\u0441\u0435\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 IPv6, UDP \u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445:from compose_audit import parse_shortfor s in [&#171;5432:5432&#187;, &#171;127.0.0.1:6379:6379&#187;, &#171;[::1]:5432:5432&#187;,          &#171;9100&#187;, &#171;53:53\/udp&#187;, &#171;8000-8005:8000-8005&#8243;]:    print(f&#187;{s!r:&lt;26} -&gt; {parse_short(s)}&#187;)&#8217;5432:5432&#8242;                -&gt; (&#8216;0.0.0.0&#8217;, &#8216;5432&#8217;, &#8216;5432&#8217;)&#8217;127.0.0.1:6379:6379&#8242;      -&gt; (&#8216;127.0.0.1&#8217;, &#8216;6379&#8217;, &#8216;6379&#8217;)'[::1]:5432:5432&#8242;          -&gt; (&#8216;::1&#8217;, &#8216;5432&#8217;, &#8216;5432&#8217;)&#8217;9100&#8242;                     -&gt; (&#8216;0.0.0.0&#8217;, None, &#8216;9100&#8217;)&#8217;53:53\/udp&#8217;                -&gt; (&#8216;0.0.0.0&#8242;, &#8217;53&#8217;, &#8217;53&#8217;)&#8217;8000-8005:8000-8005&#8242;      -&gt; (&#8216;0.0.0.0&#8217;, &#8216;8000-8005&#8217;, &#8216;8000-8005&#8217;)\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f: \u0434\u043b\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u00ab\u0442\u043e\u0440\u0447\u0438\u0442 \u043b\u0438 \u043d\u0430\u0440\u0443\u0436\u0443\u00bb \u043e\u043d \u043d\u0435 \u0432\u0430\u0436\u0435\u043d. \u0414\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443 \u2014 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0438\u0442\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043a\u0430\u0436\u0434\u044b\u0439. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432\u0438\u0434\u0430 ${DB_PORT} \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442; \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c, \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0430\u0443\u0434\u0438\u0442 \u043f\u043e \u0432\u044b\u0432\u043e\u0434\u0443 docker compose config, \u0433\u0434\u0435 \u0432\u0441\u0451 \u0443\u0436\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u043e.\u0421\u043a\u0440\u0438\u043f\u0442 2: \u0447\u0442\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043b\u043e\u0432\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445, \u043d\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 docker run -p, \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0440\u0435\u0448\u0438\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c 0.0.0.0. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u2014 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0436\u0438\u0432\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443.\u041c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c ss -tlnp, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0447\u0443\u0436\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u042f\u0434\u0440\u043e \u0438 \u0442\u0430\u043a \u043e\u0442\u0434\u0430\u0451\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0432 \/proc\/net\/tcp \u0438 \/proc\/net\/tcp6: \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 0A \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 LISTEN.import ipaddressimport socketimport structdef hex_to_ip(h: str) -&gt; str:    if len(h) == 8:  # IPv4, little-endian        return socket.inet_ntoa(struct.pack(&#171;&lt;I&#187;, int(h, 16)))    # IPv6: \u0447\u0435\u0442\u044b\u0440\u0435 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430, \u043a\u0430\u0436\u0434\u043e\u0435 little-endian    raw = b&#187;&#187;.join(struct.pack(&#171;&lt;I&#187;, int(h[i:i + 8], 16)) for i in range(0, 32, 8))    return str(ipaddress.IPv6Address(raw))def listeners():    for path in (&#171;\/proc\/net\/tcp&#187;, &#171;\/proc\/net\/tcp6&#187;):        with open(path) as f:            next(f)            for line in f:                cols = line.split()                if cols[3] != &#171;0A&#187;:  # 0A = TCP_LISTEN                    continue                ip_hex, port_hex = cols[1].split(&#171;:&#187;)                yield hex_to_ip(ip_hex), int(port_hex, 16)if __name__ == &#171;__main__&#187;:    for ip, port in sorted(set(listeners()), key=lambda x: x[1]):        addr = ipaddress.ip_address(ip)        scope = &#171;\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e&#187; if addr.is_loopback else &#171;\u0421\u041d\u0410\u0420\u0423\u0416\u0418&#187;        print(f&#187;{scope:&lt;9} {ip}:{port}&#187;)\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u043e\u0434\u043d\u044f\u043b \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u2014 \u043e\u0434\u0438\u043d \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445, \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 loopback:$ python3 -m http.server 18080 &#8212;bind 0.0.0.0 &gt;\/dev\/null 2&gt;&amp;1 &amp;$ python3 -m http.server 18081 &#8212;bind 127.0.0.1 &gt;\/dev\/null 2&gt;&amp;1 &amp;$ python3 listeners.py | grep 1808\u0421\u041d\u0410\u0420\u0423\u0416\u0418   0.0.0.0:18080\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e  127.0.0.1:18081\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 Docker \u0432\u043a\u043b\u044e\u0447\u0451\u043d userland-proxy (&#8212;userland-proxy=true), \u0438 \u0434\u043b\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 docker-proxy, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0442 \u043f\u043e\u0440\u0442 \u0441\u043b\u0443\u0448\u0430\u0435\u0442. \u0422\u0430\u043a \u0447\u0442\u043e 0.0.0.0:5432 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0415\u0441\u043b\u0438 userland-proxy \u0443 \u0432\u0430\u0441 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, \u0441\u043e\u043a\u0435\u0442\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0430 NAT-\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u2014 \u0442\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 docker ps \u0438\u043b\u0438 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430.\u041f\u043e\u0447\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \/proc \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u00ab\u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0451\u0434\u00bb\u0410\u0434\u0440\u0435\u0441 IPv4 \u0432 \/proc\/net\/tcp \u2014 \u044d\u0442\u043e 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0431\u0430\u0439\u0442\u043e\u0432 \u0445\u043e\u0441\u0442\u0430, \u0430 \u043d\u0430 x86 \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 ARM-\u043c\u0430\u0448\u0438\u043d \u044d\u0442\u043e little-endian. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 127.0.0.1 \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u043a\u0430\u043a 0100007F. \u041e\u0442\u0441\u044e\u0434\u0430 struct.pack(&#171;&lt;I&#187;, &#8230;) \u043f\u0435\u0440\u0435\u0434 inet_ntoa. \u0421 IPv6 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441 \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430, \u0438 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u043d\u0435 \u0432\u0441\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u041f\u043e\u0440\u0442, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c, \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 int(&#8230;, 16).\u041a\u0430\u043a \u0447\u0438\u043d\u0438\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0430\u0445\u043e\u0434\u043a\u0438 \u0440\u0435\u0446\u0435\u043f\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439.OPEN (\u0431\u0430\u0437\u0430, \u0430\u0434\u043c\u0438\u043d\u043a\u0430, \u0431\u0440\u043e\u043a\u0435\u0440). \u041f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043a loopback: &#171;127.0.0.1:5432:5432&#187;. \u0421 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0430 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0442\u0443\u043d\u043d\u0435\u043b\u044c: ssh -L 5432:127.0.0.1:5432 user@server, \u0430 DBeaver \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a localhost:5432. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0441\u0435\u043a\u0446\u0438\u044f ports \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0432\u0441\u0435: \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 compose-\u0441\u0435\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432\u0438\u0434\u044f\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438.RANDOM. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u00ab\u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c\u00bb \u043f\u043e\u0440\u0442. \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u2014 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443. \u0415\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u0441\u043d\u0430\u0440\u0443\u0436\u0438, \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0435\u0433\u043e \u044f\u0432\u043d\u043e \u0438 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c.\u041f\u043e\u0434\u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0435\u043c\u043e\u043d\u0430. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0440\u0442\u043e\u0432 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 bridge-\u0441\u0435\u0442\u044f\u0445 (\u0430 compose \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0445). \u0412 \/etc\/docker\/daemon.json:{  &#171;default-network-opts&#187;: {    &#171;bridge&#187;: {      &#171;com.docker.network.bridge.host_binding_ipv4&#187;: &#171;127.0.0.1&#187;    }  }}\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 &#171;5432:5432&#187; \u0431\u0435\u0437 \u0430\u0434\u0440\u0435\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e loopback, \u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u044b \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#171;0.0.0.0:443:443&#187;. \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430 Swarm-\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u044d\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442: \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e\u0442\u0441\u044f \u043d\u0430 0.0.0.0. \u0418 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0436\u0435: \u0432 \u0440\u0435\u043b\u0438\u0437\u0430\u0445 Docker \u0441\u0442\u0430\u0440\u0448\u0435 28.0.0 \u0434\u0430\u0436\u0435 \u043f\u043e\u0440\u0442 \u043d\u0430 127.0.0.1 \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0445\u043e\u0441\u0442\u0430\u043c \u0438\u0437 \u0442\u043e\u0433\u043e \u0436\u0435 L2-\u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u0430\u0440\u044b\u0439 Docker, \u044d\u0442\u043e \u043f\u043e\u0432\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f.\u041a\u0443\u0434\u0430 \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0423 \u043c\u0435\u043d\u044f \u043e\u0431\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0436\u0438\u0432\u0443\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439. compose_audit.py \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 CI \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 compose-\u0444\u0430\u0439\u043b, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 docker compose config, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 override-\u0444\u0430\u0439\u043b\u044b \u0431\u044b\u043b\u0438 \u0443\u0436\u0435&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-501609","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/501609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=501609"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/501609\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=501609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=501609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=501609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}