Accessing Ports Inside Docker AI Sandboxes (Workaround)

Published: (February 23, 2026 at 11:25 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

Docker Sandboxes (experimental) give AI coding agents a secure microVM environment, but they currently lack native port forwarding. The following workaround uses socat on the host and netcat inside the sandbox to tunnel TCP traffic through docker sandbox exec -i.

Prerequisites

Host machine

socat must be installed.

OSInstall command
macOSbrew install socat
Linux / WSLsudo apt install socat

Inside the sandbox

The OpenBSD version of netcat is required.

# Open a shell inside the sandbox
docker sandbox exec -it  bash

# Install netcat-openbsd (Debian/Ubuntu based agents)
sudo apt update
sudo apt install netcat-openbsd
# Do NOT install netcat-traditional

Run the socat tunnel

Replace “ and the internal port as needed. In this example:

  • Sandbox name: claude-my-project
  • Web server inside sandbox: port 37777
socat TCP-LISTEN:37777,fork,reuseaddr EXEC:"docker sandbox exec -i claude-my-project nc 127.0.0.1 37777"

Leave this command running in the terminal.

How it works

PartExplanation
TCP-LISTEN:37777Listens on port 37777 on the host.
fork,reuseaddrAllows multiple concurrent connections (e.g., HTML, CSS, JS).
EXEC:"docker sandbox exec -i …"Executes docker sandbox exec interactively (no TTY) so stdin/stdout stay open.
nc 127.0.0.1 37777Forwards the incoming stream to the server running inside the sandbox.

Access the application

Open a browser on the host and navigate to:

http://localhost:37777

You should see the web application that the AI agent started inside the Docker Sandbox.

Conclusion

Until Docker adds official port‑exposure support for AI Sandboxes, the socat + nc combination provides a reliable way to preview services running inside the sandbox. Happy coding with your AI agents! 🤖🐳

0 views
Back to Blog

Related posts

Read more »

DevOps and Vibe Coding: A Journey

Things to Do Map Your Application - Map your application on paper, in a spreadsheet, or using graphics/flowcharts. This is the first step. - Understanding the...

OpenAI just raised $110 billion. Wow

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as we...