Skip to content

martinffx/ib-gateway-docker

 
 

Repository files navigation

ib-gateway-docker

A Docker image running Interactive Brokers Gateway with IbcAlpha/IBC for headless automation and a VNC server for debugging.

Quick Start

  1. Copy and configure your credentials:
cp .env.example .env
# Edit .env with your IB paper trading credentials
  1. Start the container:
make up

This exposes:

  • Port 4002 — TWS API for programmatic trading
  • Port 5900 — VNC for debugging (password: password)
  1. Connect with ib_insync:
from ib_insync import IB

ib = IB()
ib.connect('localhost', 4002, clientId=1)

# Example: get Apple stock details
aapl = Stock('AAPL', 'SMART', 'USD')
ib.qualifyContracts(aapl)
print(aapl)

ib.disconnect()

Configuration

Set these in your .env file:

Variable Description
TWSUSERID IB account username
TWSPASSWORD IB account password
TRADING_MODE paper (default) or live
VNC_PASSWORD VNC server password

Building & Releasing

Build a new image:

make build

Create a versioned release (from main branch with a clean working tree):

make release

This tags the image as v<TWS_VERSION>-ibc<IBC_VERSION> and pushes it to Docker Hub via GitHub Actions.

Security

⚠️ This container is not secure for public internet access.

  • Never commit .env — it is .gitignored by default
  • Change the default VNC password (password) before exposing port 5900
  • Only run on trusted networks; place a secure reverse proxy or VPN in front if remote access is needed
  • Port 4002 (TWS API) and 5900 (VNC) have no built-in authentication beyond the VNC password

About

Interactive Brokers Gateway as a Docker image

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Dockerfile 46.3%
  • Makefile 35.0%
  • Shell 18.7%