A Docker image running Interactive Brokers Gateway with IbcAlpha/IBC for headless automation and a VNC server for debugging.
- Copy and configure your credentials:
cp .env.example .env
# Edit .env with your IB paper trading credentials- Start the container:
make upThis exposes:
- Port 4002 — TWS API for programmatic trading
- Port 5900 — VNC for debugging (password:
password)
- 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()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 |
Build a new image:
make buildCreate a versioned release (from main branch with a clean working tree):
make releaseThis tags the image as v<TWS_VERSION>-ibc<IBC_VERSION> and pushes it to Docker Hub via GitHub Actions.
- 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