localhost-bridge for Openclaw

A networking utility that bridges Docker containers to host-side localhost services using socat and systemd for seamless AI agent deployments.

superworldsavior
v2.0.0
Feb 27, 2026
0
1.2k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install localhost-bridge

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install localhost-bridge using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is localhost-bridge?

The localhost-bridge skill is a specialized networking utility designed to solve the common localhost trap where containerized AI agents are unable to reach services bound to 127.0.0.1 on the host machine. By leveraging Openclaw Skills, developers can create a secure tunnel from the Docker bridge interface to the host's loopback address. This ensures that internal services like AI gateways, local LLMs, or databases remain private and secure while being fully accessible to containerized workflows.

This implementation focuses on technical robustness and persistence. It utilizes systemd services to maintain connectivity across reboots and incorporates scoped UFW firewall rules to ensure that bridged services are never exposed to the public internet. This makes it an essential tool for those managing complex Openclaw Skills environments on Linux hosts.

localhost-bridge Use Cases

  • Accessing host-bound AI gateways like OpenClaw or LiteLLM from within a container.
  • Connecting dockerized agents to local Model Context Protocol (MCP) servers running on the host.
  • Allowing RAG pipelines inside containers to query an Ollama instance running on 127.0.0.1.
  • Interfacing containerized API servers with local PostgreSQL or Redis database instances.
  • Bridging workflow orchestrators like Windmill or n8n to host-level development services.

How localhost-bridge Works

  1. The administrator identifies the specific Docker bridge gateway IP address for the target container network using docker inspect.
  2. A persistent systemd service is created on the host to run a socat process.
  3. The socat process listens on the Docker bridge IP and forwards all incoming traffic to the host's loopback address (127.0.0.1) on the specified port.
  4. A mandatory UFW firewall rule is added to the Linux bridge interface to allow the container traffic to reach the socat listener.
  5. The containerized application then connects to the host service by targeting the bridge gateway IP instead of localhost.

localhost-bridge Setup

1. Install Dependencies

Ensure socat is installed on your host system:

sudo apt-get install -y socat

2. Identify Gateway IP

Find the gateway for the Docker network your Openclaw Skills containers use:

# Replace <container_name> with your agent container
docker inspect <container_name> --format '{{json .NetworkSettings.Networks}}' | python3 -c "import json,sys; d = json.load(sys.stdin); [print(f'{n}: gateway={i[\"Gateway\"]}') for n, i in d.items()]"

3. Configure Systemd

Create the bridge service (replace <GATEWAY_IP>, <PORT>, and <SERVICE_NAME>):

sudo tee /etc/systemd/system/socat-<SERVICE_NAME>.service > /dev/null << 'EOF'
[Unit]
Description=Socat bridge for Openclaw Skills
After=network.target docker.service

[Service]
Type=simple
ExecStart=/usr/bin/socat TCP-LISTEN:<PORT>,bind=<GATEWAY_IP>,fork,reuseaddr TCP:127.0.0.1:<PORT>
Restart=always

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now socat-<SERVICE_NAME>

4. Update Firewall

Allow traffic from the specific Docker bridge interface:

BRIDGE_ID=$(docker network inspect bridge --format '{{.Id}}' | cut -c1-12)
sudo ufw allow in on br-${BRIDGE_ID} to any port <PORT> proto tcp

localhost-bridge Data Schema & Taxonomy

The localhost-bridge skill organizes network configuration and service metadata on the host system to ensure clarity and security:

Component Path / Location Description
Systemd Service /etc/systemd/system/socat-*.service Defines the listener binding and forwarding target.
Firewall Rule ufw status (br-XXXX interface) Scoped access control for the Docker network bridge.
Naming Convention socat-<net>-<service>-<port> Self-documenting identifier for the bridge instance.
Logs journalctl -u socat-* Real-time monitoring of connection attempts and errors.

localhost-bridge Advanced Features

  • Multi-network workers support: Configure multiple socat instances for containers attached to several Docker bridges.
  • Persistent connectivity: Automated service recovery via systemd's Restart logic ensures no downtime for Openclaw Skills.
  • Scoped isolation: Prevents services from binding to 0.0.0.0, maintaining strict local-only access.
  • Custom Port Mapping: Ability to bridge host services to different ports within the container network.
  • Low-latency forwarding: High-performance packet relaying using native Linux socat utilities.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*