<?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: JJ</title>
    <description>The latest articles on DEV Community by JJ (@miyamiyaz).</description>
    <link>https://dev.to/miyamiyaz</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3788177%2Fa3232ee0-fd96-4e8a-a7d6-ee245717473e.png</url>
      <title>DEV Community: JJ</title>
      <link>https://dev.to/miyamiyaz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miyamiyaz"/>
    <language>en</language>
    <item>
      <title>Accessing Ports Inside Docker AI Sandboxes (Workaround)</title>
      <dc:creator>JJ</dc:creator>
      <pubDate>Tue, 24 Feb 2026 04:25:44 +0000</pubDate>
      <link>https://dev.to/miyamiyaz/accessing-ports-inside-docker-ai-sandboxes-workaround-3jc0</link>
      <guid>https://dev.to/miyamiyaz/accessing-ports-inside-docker-ai-sandboxes-workaround-3jc0</guid>
      <description>&lt;p&gt;Docker recently introduced &lt;strong&gt;Docker Sandboxes&lt;/strong&gt; (currently Experimental), a fantastic feature that provides isolated microVM environments for AI coding agents like Claude Code, Copilot, and others. &lt;/p&gt;

&lt;p&gt;However, as of early 2026, there is one missing feature that many developers are waiting for: &lt;strong&gt;native port forwarding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If your AI agent spins up a local web server (e.g., a React app on port 3000 or a Python API on 8000) inside the sandbox, you cannot access it from your host machine's browser using the traditional &lt;code&gt;docker run -p&lt;/code&gt; approach. Official support is on the roadmap, but what if you need to preview it &lt;em&gt;right now&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Here is a quick and elegant workaround using &lt;code&gt;socat&lt;/code&gt; and &lt;code&gt;netcat&lt;/code&gt; to tunnel TCP traffic through the standard I/O of &lt;code&gt;docker sandbox exec&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Standard I/O Tunneling
&lt;/h2&gt;

&lt;p&gt;We can map a port on our host machine to a port inside the sandbox by piping a TCP connection through &lt;code&gt;docker sandbox exec -i&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;To handle multiple simultaneous connections (like loading HTML, CSS, and JS files from a browser), we will use &lt;code&gt;socat&lt;/code&gt; on the host side to fork connections, and &lt;code&gt;nc&lt;/code&gt; (netcat) on the sandbox side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Host Machine:&lt;/strong&gt; You need &lt;code&gt;socat&lt;/code&gt; installed.

&lt;ul&gt;
&lt;li&gt;Mac: &lt;code&gt;brew install socat&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Linux/WSL: &lt;code&gt;sudo apt install socat&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inside the Sandbox:&lt;/strong&gt; You need &lt;code&gt;netcat&lt;/code&gt; (specifically the OpenBSD version) installed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1: Install &lt;code&gt;netcat&lt;/code&gt; inside the sandbox
&lt;/h3&gt;

&lt;p&gt;Drop into your sandbox shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker sandbox &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &amp;lt;your-sandbox-name&amp;gt; bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the netcat-openbsd package (assuming a Debian/Ubuntu-based agent environment):&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="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;netcat-openbsd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Note: Do not install netcat-traditional as the OpenBSD version handles this workflow much better).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Open the tunnel from your Host OS
&lt;/h3&gt;

&lt;p&gt;Open a terminal on your host machine and run the following command.&lt;/p&gt;

&lt;p&gt;In this example, we assume your sandbox is named claude-my-project and the web server inside is running on port 37777.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;socat TCP-LISTEN:37777,fork,reuseaddr EXEC:&lt;span class="s2"&gt;"docker sandbox exec -i claude-my-project nc 127.0.0.1 37777"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TCP-LISTEN:37777&lt;/code&gt;: Listens on port 37777 on your host machine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fork,reuseaddr&lt;/code&gt;: Ensures that multiple concurrent browser requests don't drop the connection.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;EXEC:"... -i ..."&lt;/code&gt;: Executes the docker sandbox command interactively (keeping stdin/stdout open) without a TTY (-t), which keeps the data stream clean.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nc 127.0.0.1 37777&lt;/code&gt;: Forwards the incoming stream to the actual server running inside the sandbox.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Access it in your browser!
&lt;/h3&gt;

&lt;p&gt;Leave the socat command running in your terminal. Now, simply open your browser on your host machine and navigate to:&lt;br&gt;
&lt;a href="http://localhost:37777" rel="noopener noreferrer"&gt;http://localhost:37777&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boom! You should now see the web application that your AI agent built, running safely inside the isolated Docker Sandbox.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Until Docker officially releases the "Ability to expose ports to the host device" for AI Sandboxes, this socat + nc trick is the most reliable way to preview your agent's work in your local browser.&lt;/p&gt;

&lt;p&gt;Happy coding with your AI agents! 🤖🐳&lt;/p&gt;

</description>
      <category>ai</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
