<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dhyaan K</title>
    <description>The latest articles on DEV Community by Dhyaan K (@dhyaan_k).</description>
    <link>https://dev.to/dhyaan_k</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2344705%2F4d79d2ad-f99b-4ea1-9794-47d888c07ffb.jpg</url>
      <title>DEV Community: Dhyaan K</title>
      <link>https://dev.to/dhyaan_k</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhyaan_k"/>
    <language>en</language>
    <item>
      <title>Why Docker Silently Binds to 0.0.0.0 (And How to Trace Port Causality in Go)</title>
      <dc:creator>Dhyaan K</dc:creator>
      <pubDate>Mon, 23 Nov 2026 17:44:36 +0000</pubDate>
      <link>https://dev.to/dhyaan_k/why-docker-silently-binds-to-0000-and-how-to-trace-port-causality-in-go-26p9</link>
      <guid>https://dev.to/dhyaan_k/why-docker-silently-binds-to-0000-and-how-to-trace-port-causality-in-go-26p9</guid>
      <description>&lt;p&gt;If you've spent any time working with Docker or Docker Compose, chances are high that you've written something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"5432:5432"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It looks completely harmless. You just wanted to connect your local GUI database client (DBeaver, TablePlus, pgAdmin) to PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Except you just exposed your database to your entire local network and every public interface on your machine.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  The Silent Wildcard Footgun
&lt;/h3&gt;

&lt;p&gt;When you declare &lt;code&gt;"5432:5432"&lt;/code&gt; without an explicit host IP prefix, Docker defaults to binding to &lt;strong&gt;&lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/strong&gt; (the wildcard address in IPv4) and &lt;code&gt;::&lt;/code&gt; (in IPv6).&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your laptop is on a coffee shop or office Wi-Fi, anyone on that subnet can reach port 5432.&lt;/li&gt;
&lt;li&gt;If this runs on a cloud VM without a restrictive security group, port 5432 is open to the entire public internet.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iptables&lt;/code&gt; rules are automatically modified by the Docker daemon to bypass standard host firewalls (like UFW) unless specially configured.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To bind exclusively to your local machine, you have to remember to explicitly write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:5432:5432"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yet across millions of repositories and development stacks, developers constantly forget the &lt;code&gt;127.0.0.1:&lt;/code&gt; prefix.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Causality Black Box: &lt;code&gt;ss&lt;/code&gt; and &lt;code&gt;lsof&lt;/code&gt; Don't Help
&lt;/h3&gt;

&lt;p&gt;When you suspect an unexpected port is open and run standard Linux diagnostic commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ sudo ss -tulpn &lt;span class="o"&gt;|&lt;/span&gt; grep 5432
tcp   LISTEN 0 4096 0.0.0.0:5432 0.0.0.0:* users:&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"docker-proxy"&lt;/span&gt;,pid=14205,fd=4&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All you see is &lt;code&gt;docker-proxy&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You don't know which container owns it.&lt;/li&gt;
&lt;li&gt;You don't know which &lt;code&gt;docker-compose.yml&lt;/code&gt; file declared it.&lt;/li&gt;
&lt;li&gt;You don't know whether it was intended as public or an accidental wildcard binding.&lt;/li&gt;
&lt;li&gt;If you have 30 containers running across 5 microservices, you are left manually running &lt;code&gt;docker inspect&lt;/code&gt; across every container or grepping your codebase.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Building Lantern: Tracing Configuration Causality
&lt;/h3&gt;

&lt;p&gt;To solve this visibility gap, we built &lt;a href="https://github.com/DhyaanKanoja11/Lantern" rel="noopener noreferrer"&gt;Lantern&lt;/a&gt;, an open-source, local-first CLI written in Go.&lt;/p&gt;

&lt;p&gt;Instead of merely listing sockets, Lantern traverses the full causality graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ Listening Socket ]
        ↓
[ OS Process / docker-proxy ]
        ↓
[ Docker Container ]
        ↓
[ Docker Compose Service &amp;amp; Source YAML Line ]
        ↓
[ Reachability Verdict (PUBLIC / LOCALHOST / DOCKER) ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  1. Instant Reachability Audit (&lt;code&gt;lantern scan&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;Running &lt;code&gt;lantern scan&lt;/code&gt; audits all listening TCP sockets and classifies their exposure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ lantern scan
PORT    PROTO   BIND ADDRESS    REACHABILITY   PROCESS         CONTAINER / SOURCE
5432    tcp     0.0.0.0         PUBLIC         docker-proxy    my-project-db-1 &lt;span class="o"&gt;(&lt;/span&gt;docker-compose.yml:8&lt;span class="o"&gt;)&lt;/span&gt;
8080    tcp     127.0.0.1       LOCALHOST      node            api-gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any wildcard binding (&lt;code&gt;0.0.0.0&lt;/code&gt; or &lt;code&gt;::&lt;/code&gt;) is immediately flagged with a high-contrast &lt;strong&gt;PUBLIC&lt;/strong&gt; warning.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Root Cause Explanation (&lt;code&gt;lantern why &amp;lt;port&amp;gt;&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;If you want to know &lt;em&gt;why&lt;/em&gt; a port is open, Lantern produces the exact causal chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ lantern why 5432
Port 5432 &lt;span class="o"&gt;(&lt;/span&gt;tcp&lt;span class="o"&gt;)&lt;/span&gt; is bound to 0.0.0.0 &lt;span class="o"&gt;(&lt;/span&gt;PUBLIC&lt;span class="o"&gt;)&lt;/span&gt;
├─ Process: docker-proxy &lt;span class="o"&gt;(&lt;/span&gt;PID 14205&lt;span class="o"&gt;)&lt;/span&gt;
├─ Container: my-project-db-1 &lt;span class="o"&gt;(&lt;/span&gt;ID 8a1b2c3d4e5f&lt;span class="o"&gt;)&lt;/span&gt;
├─ Compose Service: db
└─ Defined in: /home/dev/projects/api/docker-compose.yml:8
   Recommendation: Change &lt;span class="s1"&gt;'5432:5432'&lt;/span&gt; to &lt;span class="s1"&gt;'127.0.0.1:5432:5432'&lt;/span&gt; to restrict access to localhost.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Real-Time Terminal Watch Mode (&lt;code&gt;lantern scan -w&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;Developers frequently start and stop containers. With &lt;code&gt;-w, --watch&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lantern scan -w --interval 2s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lantern renders a live terminal dashboard that triggers an &lt;code&gt;[ALERT]&lt;/code&gt; the moment a new wildcard exposure occurs.&lt;/p&gt;




&lt;h3&gt;
  
  
  Enforcing Guardrails in CI/CD
&lt;/h3&gt;

&lt;p&gt;Catching exposure on developer laptops is great, but preventing it from merging into production repositories is critical.&lt;/p&gt;

&lt;p&gt;We built two native CI mechanisms into Lantern:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Zero-Exit Flag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lantern scan --fail-on-wildcard --ignore-ports 80,443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any container or process binds to &lt;code&gt;0.0.0.0&lt;/code&gt; on a port other than 80 or 443, the command exits with code &lt;code&gt;1&lt;/code&gt; and emits native GitHub Actions error annotations (&lt;code&gt;::error::&lt;/code&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Official GitHub Action
&lt;/h4&gt;

&lt;p&gt;You can drop Lantern into any repository workflow with a few lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Security Audit&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;pull_request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;push&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;port-audit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Spin up test environment&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker compose up -d&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Audit Port Exposures&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DhyaanKanoja11/lantern-action@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;fail-on-wildcard&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt;
          &lt;span class="na"&gt;ignore-ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'80,443'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It automatically formats a rich Markdown report on your GitHub Actions Step Summary page.&lt;/p&gt;




&lt;h3&gt;
  
  
  How to Try It
&lt;/h3&gt;

&lt;p&gt;Lantern has zero runtime dependencies and is distributed across major package managers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS / Linux (Homebrew)&lt;/span&gt;
brew tap DhyaanKanoja11/tap
brew install lantern

&lt;span class="c"&gt;# Windows (Scoop)&lt;/span&gt;
scoop bucket add dhyaan &lt;span class="o"&gt;[&lt;/span&gt;https://github.com/DhyaanKanoja11/scoop-bucket&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;https://github.com/DhyaanKanoja11/scoop-bucket&lt;span class="o"&gt;)&lt;/span&gt;
scoop install lantern

&lt;span class="c"&gt;# Go toolchain&lt;/span&gt;
go install &lt;span class="o"&gt;[&lt;/span&gt;github.com/DhyaanKanoja11/Lantern/cmd/lantern@latest&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;https://github.com/DhyaanKanoja11/Lantern/cmd/lantern@latest&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Open Source &amp;amp; Getting Involved
&lt;/h3&gt;

&lt;p&gt;The entire project is MIT-licensed and built with standard library principles in Go:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/DhyaanKanoja11/Lantern" rel="noopener noreferrer"&gt;github.com/DhyaanKanoja11/Lantern&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Action:&lt;/strong&gt; &lt;a href="https://github.com/DhyaanKanoja11/lantern-action" rel="noopener noreferrer"&gt;github.com/DhyaanKanoja11/lantern-action&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've ever had a container expose an unexpected port, give &lt;code&gt;lantern scan&lt;/code&gt; a run and let us know what you think!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>go</category>
      <category>security</category>
    </item>
  </channel>
</rss>
