opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Run IB Gateway and TWS in Docker with zero human interaction
GitHub RepoImpressions2

Project Description

View on GitHub

Run Interactive Brokers Gateway and TWS in Docker Without Ever Touching the GUI

If you've ever tried to automate trading with Interactive Brokers, you know the pain: IB Gateway is a desktop application that expects a human to log in, click through dialogs, and keep a session alive. It doesn't play nicely with headless servers or CI pipelines. You've probably found yourself wondering if there's a way to run it as a proper service, something you can containerize, restart, and forget about.

That's exactly what ib-gateway-docker solves. It's a Docker image that runs IB Gateway and Trader Workstation (TWS) with zero human interaction, bundling everything you need to keep your trading infrastructure running unattended.

What It Does

This project packages IB Gateway and TWS into Docker images that boot up, log in, and stay connected without anyone watching. Under the hood, it combines several tools to make that happen:

  • IBC (Interactive Brokers Controller) simulates user input to handle the login flow and dismiss pop-up dialogs automatically.
  • Xvfb provides a virtual X11 framebuffer, so the GUI applications think they're running on a display even when there's no monitor attached.
  • x11vnc is included optionally if you want to peek at the UI for debugging or maintenance.
  • socat relays TCP connections from outside the container to IB Gateway's localhost port, since IB restricts connections to 127.0.0.1 by default.
  • For TWS specifically, the image builds on top of linuxserver/rdesktop to provide an xrdp/xfce environment.

The project supports both the stable and latest channels of IB Gateway, lets you run live and paper trading modes in parallel, and has included aarch64 support since version 10.37.1l, so it works on Raspberry Pi and Apple Silicon machines.

Why It's Cool

The obvious win here is that you can finally treat IB Gateway like infrastructure instead of a fragile desktop app you have to babysit. But there are a few design decisions that make this project genuinely thoughtful:

  • Secrets support: You don't have to hardcode your IB credentials in environment variables or compose files. The image supports Docker secrets (available in recent versions), which is the right way to handle sensitive data in containerized deployments.

  • Start-up scripts: You can drop custom scripts into the container that execute during the boot process. That's handy for injecting your own configuration, waiting for certain conditions, or wiring up sidecar services before the gateway finishes starting.

  • Remote SSH tunneling: For newer versions, you can set up SSH tunnels to securely expose both IB Gateway and VNC ports. That's a nice touch for anyone who doesn't want to open raw ports to the world.

  • It plays well with others: The README mentions it works smoothly with Jupyter Quant, so you can run your research notebooks and live trading connections side by side in the same Docker ecosystem.

  • Parallel live and paper: Being able to run both trading modes simultaneously from the same setup is genuinely useful for testing strategies against live market data while your paper account runs experiments.

The version tags are also well organized — you get granular tags like 10.50 and 10.50.1e alongside the rolling latest and stable channels, so you can pin to a specific version when you need reproducibility, or ride the update train when you don't.

How to Try It

Getting started is straightforward. The repository provides sample docker-compose.yml files you can use as a starting point. Here's the general shape of what you'd do:

  1. Head over to the repository and grab the sample compose files.
  2. Create your own docker-compose.yml or adapt the existing one with your IB credentials and trading mode settings.
  3. Pull the image and start the container:
docker-compose up -d

The available images are ib-gateway and tws-rdesktop, with tags like latest, stable, and version-specific tags such as 10.50 or 10.45.1j. If you need to interact with the GUI for debugging, you can connect via VNC (for IB Gateway) or RDP (for TWS).

For production use, make sure you're on a version that supports secrets (latest 10.29.1e or stable 10.19.2m and greater) and look into the SSH tunnel options if you're exposing services beyond localhost.

Final Thoughts

If you're building automated trading systems on Interactive Brokers, this project removes one of the most annoying operational hurdles. It's not flashy—it's just a solid, well-maintained Docker image that does exactly what it promises. The attention to details like secrets management, aarch64 support, and start-up hooks tells you the maintainer actually runs this in production and cares about the rough edges.

This is best suited for developers who already have their trading logic in code and want their broker connection to be just another container in the stack. It won't write your trading strategy for you, but it will make sure your gateway is up, logged in, and ready when your strategy needs it.


Follow @githubprojects for more developer tools and open source projects.

Back to Projects
Project ID: 684c54e6-b534-452c-94e9-407b3bd0db76Last updated: September 6, 2026 at 04:21 AM