Running the InstaWormhole connector in a container is a good fit for a server or a build job. The official guide describes it as a way to run the connector as a non-root user, and it applies to Connector 0.2.0. A few details differ from what you might expect from a typical Docker workflow: there is no published image, containers have no operating system credential store, and the connector only accepts loopback origins. This guide covers what the documentation supports and explains how to handle each of those constraints.
What to know before you start
Three facts shape everything else in a Docker setup:
- There is no published container image yet. The image definition lives in the connector’s source tree at
distribution/docker/Dockerfile, so you build the image yourself. - A container has no operating system credential store. Instead of a saved sign-in, you pass a one-use credential to the connector on standard input.
- The connector only accepts loopback origins. It refuses anything that is not a loopback address for
--origin, and a configuration file that names a non-loopback origin is refused too.
You need Docker and a copy of the connector’s source tree.
Build the image
From the root of the connector’s source tree, build the image from the Dockerfile in distribution/docker:
docker build -t instawormhole/connector -f distribution/docker/Dockerfile . Docker should report that the image was built and tagged instawormhole/connector. The image runs the connector as a non-root user.
Run the connector with a credential on standard input
Pass the credential with --credential-stdin and feed it to the container with -i and a redirect:
docker run --rm -i instawormhole/connector run \ --relay wss://relay.instawormhole.site \ --origin 127.0.0.1:3000 \ --credential-stdin < credential.txt When the connector starts, the container prints the public address for your app. The options in this command work as follows:
| Option | What it does |
|---|---|
--relay <address> | The InstaWormhole relay to connect to. Use wss://relay.instawormhole.site. |
--origin <address> | The loopback address your app listens on, for example 127.0.0.1:3000. |
--credential-stdin | Reads a one-use credential from standard input instead of using the saved sign-in. Useful in containers and scripts. |
Note that the origin is written as an address such as 127.0.0.1:3000, not as a full URL.
Choose the right networking mode
Inside a container, 127.0.0.1 refers to the container itself, not your host or other containers. Because the connector refuses non-loopback origins, you cannot point --origin at a hostname such as a Compose service name. Instead, make your app reachable on the connector’s own loopback address. The documentation describes two ways to do that:
| Where your app runs | What to do |
|---|---|
| On the Linux host | Add --network host. Then 127.0.0.1 reaches services on the host. |
| In another container | Run the connector in the same network namespace as your app, for example with --network container:<app>. |
For an app running in a container named my-app and listening on port 3000, that looks like this:
docker run --rm -i --network container:my-app instawormhole/connector run \ --relay wss://relay.instawormhole.site \ --origin 127.0.0.1:3000 \ --credential-stdin < credential.txt Be aware that --network host removes the network isolation between the container and your host. Use it only when your app is running directly on a Linux host and you need the connector to reach it.
Keep the credential secret
The credential is what lets the connector open tunnels for your account, so treat it like any other secret:
- Store it in your platform’s secret store, not in the image, your command history or your repository.
- Never bake it into the image or pass it as a command-line argument.
- Feed it through standard input as shown above, and keep the file you redirect from out of version control.
The documentation also explains how to end access when you no longer need a computer or runner. Sign out with the logout command, or revoke the device under Connectors and devices in the dashboard.
Durable tunnels and several tunnels
The run command above opens a connection without naming a tunnel. A durable tunnel keeps its address, can be protected and shows its requests in the inspector. Add --tunnel <tunnel id> to connect to a durable tunnel from the dashboard instead of opening a temporary address. The dashboard’s Connect an app section shows the command to copy.
The connector can also start several tunnels from one instawormhole.toml file, up to 10 tunnels from one connector process. The file format is strict:
relay = "wss://relay.instawormhole.site" [[tunnel]] name = "web" origin = "127.0.0.1:3000" [[tunnel]] name = "api" origin = "127.0.0.1:8080" You start it with --config instawormhole.toml, and the documentation says --config needs --stored-device. The Docker guide does not describe using a configuration file in a container, so check that your setup can provide a stored sign-in before relying on this approach.
Timeouts and reconnection
Two behaviors are useful to know when the connector runs unattended:
- Reconnecting: If the connection drops, for example when your computer sleeps, the connector reconnects on its own, and a durable tunnel keeps its address.
- Origin timeouts:
--origin-timeout <seconds>sets how long to wait for your app to answer or to send more, from 1 to 3600 seconds. The defaults are 10 minutes to wait for a response to start and 2 minutes with no data.
To stop the connector, stop the container. The public address stops answering when the connector stops.
Troubleshooting
Use the diagnostic codes from Tunnel Doctor to find the failing layer. Tunnel Doctor runs from the dashboard for a durable tunnel, and you can run it once every 10 seconds. It checks DNS, TLS, the tunnel’s state, the connector, access protection, your app and a request through the public address. Codes you are most likely to meet with a containerized connector:
-
CONNECTOR_OFFLINE: Start the connector on the computer running your app, using the command under Connect an app. If it is running, look at its output for an error. -
CONNECTOR_UNAVAILABLE: The connector is recorded as connected but did not take the request. Restart it, then use the command under Connect an app. -
ORIGIN_UNREACHABLE: Make sure your app is running and that the--originaddress in the connector command matches the port it listens on, for example127.0.0.1:3000. In Docker, this also means checking that the connector shares a network namespace with your app. -
ORIGIN_SLOW: Your app accepted the request but did not answer within 15 seconds. Check whether it is busy or stuck. -
config_invalid: The connector stops with this error when aninstawormhole.tomlfile breaks the strict format. Only the documented keys are allowed, with plain double-quoted strings and#comments, and up to 10 tunnels.
Tunnel Doctor sends one request from the InstaWormhole edge, so it is not an independent outside check. Your app receives it with an X-Instawormhole-Diagnostic header, which makes it easy to spot in your logs.
A short safety checklist
- Build the image yourself from the connector’s source tree, since no published image exists.
- Keep the credential out of the image, your command history and your repository.
- Use loopback origins only, with
--network hoston Linux or--network container:<app>for another container. - Reserve
--network hostfor cases that need it, because it removes network isolation. - Revoke devices you no longer use with
logoutor from Connectors and devices in the dashboard.
For the latest instructions, see the Run the connector in Docker page in the InstaWormhole documentation.
Originally published at https://instawormhole.com/blog/run-the-instawormhole-connector-in-docker-safely


