Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
9c0313f
Updates to mvberg/ib-gateway-docker to use the 978 version of Interac…
forhire Jul 28, 2020
0dac563
Update version in README.md to 978.2d
forhire Jul 28, 2020
7cfda01
Update to Ubuntu 20:04. Add SOCAT back, but start it in the backgroun…
forhire Aug 1, 2020
b4e6a34
Add Packer build scripts as alternative to Dockerfile
forhire Aug 31, 2020
0e94fd6
Update Packer build with newest IBC instead of the old IBContoller
forhire Aug 31, 2020
6d5d23c
Updates to Hashicorp Packer install to reduce image size
forhire Sep 1, 2020
2a99c39
Create docker-image.yml
forhire Jan 5, 2021
1c88bee
Update configuration
forhire Jan 5, 2021
8ed92f4
Update Dockerhub location in README.md
forhire Jan 5, 2021
3b2086b
Update Dockerfile to try to reduce image layers
forhire Jan 5, 2021
6fd860d
Update runscript with /opt/IBController/Scripts/DisplayBannerAndLaunc…
forhire Jan 6, 2021
895b656
Add reference to HELM3 module in docs
forhire Jan 6, 2021
b43f84d
Minor cleanup Dockerfile. Update runscript to watch for IB port befor…
forhire Jan 12, 2021
f43cee5
Create docker-publish.yml
forhire Jan 12, 2021
ed1a87e
Delete docker-image.yml
forhire Jan 12, 2021
960953f
Update socat in runscript
forhire Jan 12, 2021
fc26689
Update socat in runscript to fork with detail output
forhire Jan 12, 2021
339ab1a
Update Dockerfile to reduce image size
forhire Jan 14, 2021
28cab94
Stop copying jts.ini since it should be created automatically. Update…
forhire Feb 4, 2021
ebf8967
Update IBC in readme
forhire Feb 4, 2021
a6de4a6
Update runscript to remove tail logs, since they can be sent to stdou…
forhire Feb 4, 2021
8ebb6ba
Update with SOCAT env vars
forhire Feb 4, 2021
b714ee2
Update with SOCAT env vars. Clean up runscript.
forhire Feb 4, 2021
7037db9
Update docker-compose.yaml with correct socat port
forhire Mar 5, 2021
530ec32
Update to IBC 3.8.5
forhire Mar 9, 2021
214c5da
Update to IBC 3.8.5
forhire Mar 9, 2021
92f0dbb
Cleanup Dockerfile
forhire May 19, 2021
79e5722
Update to latest IBC to enable SSL
forhire Feb 11, 2022
c7f0456
Update for IBGW install change
forhire Feb 11, 2022
9a89644
Update IBGW version in docker-compose.yml
forhire Feb 11, 2022
fcf2926
Update to IBC 3.14.0
forhire Jul 26, 2022
ee6d6ac
Update docker-compose for new versions
forhire Jul 27, 2022
b56f413
Update Dockerfile
forhire Mar 2, 2023
51abc41
Update docker-compose.yml
forhire Mar 2, 2023
12e1a6a
Update Ubuntu version
forhire Mar 2, 2023
97267e7
Update IBC to 3.16.0, update IBGW to 1021
forhire Mar 3, 2023
fd1a911
Merge pull request #1 from forhire/update_docker
forhire Mar 3, 2023
f266c2f
Update IBGW to 1021
forhire Mar 3, 2023
a9ff322
Update Github actions
forhire Mar 3, 2023
3fd4713
Update Github actions to GITHUB_STATE
forhire Mar 3, 2023
d009b27
Update healthcheck
forhire Mar 3, 2023
6aa79b0
Update ncat for healthcheck
forhire Mar 3, 2023
e2408ac
Cleanup Github actions to remove redundant test step
forhire Mar 3, 2023
a5faf79
Update health check, updated to stable release.
forhire Mar 4, 2023
a9fe2d1
Updating documentation, updating docker-compose to new ports. Updatin…
forhire Mar 5, 2023
9d1f308
Updating Semver for containers
forhire Mar 5, 2023
408398f
Rollback Github workflow docker-publish.yml
forhire Mar 5, 2023
c94e3a2
Test semver
forhire Mar 6, 2023
24bf871
Test semver
forhire Mar 6, 2023
dc0ffda
Merge pull request #2 from forhire/semver
forhire Mar 6, 2023
55de66a
Fix symbol in workflow
forhire Mar 6, 2023
20fd77f
Fix error in workflow
forhire Mar 6, 2023
7ad7456
Fix error in workflow
forhire Mar 6, 2023
649c3d3
Update semver library in workflow
forhire Mar 6, 2023
d2771b4
Test updates to semver
forhire Mar 7, 2023
89b2d5c
Test updates to semver
forhire Mar 7, 2023
1975590
Update to build a container on a successful PR merge
forhire Mar 7, 2023
40a9fde
Merge pull request #3 from forhire/semver
forhire Mar 7, 2023
92b1677
Update GH actions to recent versions
forhire Mar 8, 2023
a12c23f
Testing new Semver release library
forhire Mar 8, 2023
e6a2ee4
Testing new Semver release library
forhire Mar 8, 2023
9829595
Revert new Semver release library
forhire Mar 8, 2023
658d7ee
Test Semver library
forhire Mar 8, 2023
f0419cf
Test Semver library
forhire Mar 8, 2023
45710b3
Revert new Semver release library
forhire Mar 8, 2023
4571199
Test semver release
forhire Mar 8, 2023
cd6cc1f
Update to include tags for semver release
forhire Mar 8, 2023
ac1ecb7
Update Github actions versions for semver
forhire Mar 8, 2023
fe602a6
Update healthcheck.py
forhire Mar 9, 2023
f5e4499
Update healthcheck.py in Dockerfile
forhire Mar 9, 2023
95b692e
Update healthcheck.py in Dockerfile to disconnect and end after succe…
forhire Mar 9, 2023
7c6906a
MINOR: Update Dockerfile to use more variables, reorg, cleanup
forhire Mar 9, 2023
53ad07e
MINOR: Update Dockerfile to use more variables
forhire Mar 9, 2023
b0e22a2
Update healhcheck
forhire Mar 10, 2023
1ada908
Update health check to also look for NextValidID to ensure that IB is…
forhire Mar 15, 2023
8306ee1
Updates to semver
forhire Mar 15, 2023
6e26cfc
Updating startup scripts
forhire Mar 16, 2023
c038e31
Commit healthcheck updates to avoid multiple processes running
forhire Mar 16, 2023
19a5a33
Update new IBC config
forhire Mar 16, 2023
87b703a
Merge pull request #4 from forhire/update_startup
forhire Mar 16, 2023
52a3d0e
Investigating opccasional xvfb startup issue. Found a possible workar…
forhire Mar 17, 2023
9f98738
Working on converting from xvfb-run
forhire Mar 18, 2023
926677a
Update to use vncserver
forhire Mar 18, 2023
c6f2271
Updates to vncserver start, healthcheck
forhire Mar 18, 2023
419698e
Update run script to remove lock file, if it exists and Xtightvnc is …
forhire Mar 18, 2023
878c1ad
Merge pull request #5 from forhire/change_xvnc
forhire Mar 18, 2023
e0460b6
Bump: major update to VNC and startup process
forhire Mar 18, 2023
71d5804
Update runscript to also remove /tmp/.X11-unix/X0 on boot. May furthe…
forhire Mar 19, 2023
5a2bc48
Update IBGW and IBC version
forhire Sep 13, 2023
3b49e2b
Update version
forhire May 7, 2024
b0557b2
Update IBC version to include -Update.1
forhire May 7, 2024
b820d2b
Update IBC version
forhire Aug 6, 2024
57276dc
Update IBC
forhire Aug 7, 2024
d1f6743
Update IBC config with master client 1000 for testing
forhire Aug 7, 2024
5f22680
Update IBC config
forhire Aug 7, 2024
66eb752
Update IBC config
forhire Aug 7, 2024
931fe7d
Update IBC config
forhire Aug 7, 2024
3d38054
Update IBC version
forhire Aug 17, 2024
b2faa16
Update IBC and IB Gatway version
invalid-email-address Mar 24, 2025
37bbd78
Update IB API version
invalid-email-address Mar 24, 2025
d9913b6
Update versions
invalid-email-address Apr 28, 2025
88063c4
Create docker-image.yml
forhire May 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Docker Image CI

on:
pull_request:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
57 changes: 57 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker

on:
push:
branches:
- master
tags:
- v*

pull_request:

env:
IMAGE_NAME: ib-gateway-docker

jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout code
uses: actions/checkout@v3.3.0

with:
fetch-depth: 0

- name: Get version from tag
id: version
run: echo "name=version::$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT

- name: Set up semantic versioning
id: semver
uses: paulhatch/semantic-version@v5.0.3

with:
bump: patch
version: ${{ steps.version.outputs.version }}

- name: Build Docker image
run: docker build . --file Dockerfile --tag "ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ steps.semver.outputs.version }}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Tag and push Docker image
if: github.event_name == 'push'
id: push-image
run: |
docker push "ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ steps.semver.outputs.version }}"

echo "name=image-url::ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ steps.semver.outputs.version }}" >> $GITHUB_OUTPUT
echo "name=image-tag::${{ steps.semver.outputs.version }}" >> $GITHUB_OUTPUT

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Logs/*
node_modules/

*.local
.env*
138 changes: 92 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,102 @@
FROM ubuntu:16.04

LABEL maintainer="Mike Ehrenberg <mvberg@gmail.com>"

RUN apt-get update \
&& apt-get install -y wget \
&& apt-get install -y unzip \
&& apt-get install -y xvfb \
&& apt-get install -y libxtst6 \
&& apt-get install -y libxrender1 \
&& apt-get install -y libxi6 \
&& apt-get install -y x11vnc \
&& apt-get install -y socat \
&& apt-get install -y software-properties-common \
&& apt-get install -y dos2unix

# Setup IB TWS
RUN mkdir -p /opt/TWS
WORKDIR /opt/TWS
RUN wget -q http://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64-v974.4g.sh
RUN chmod a+x ibgateway-latest-standalone-linux-x64-v974.4g.sh

# Setup IBController
RUN mkdir -p /opt/IBController/ && mkdir -p /opt/IBController/Logs
WORKDIR /opt/IBController/
RUN wget -q http://cdn.quantconnect.com/interactive/IBController-QuantConnect-3.2.0.5.zip
RUN unzip ./IBController-QuantConnect-3.2.0.5.zip
RUN chmod -R u+x *.sh && chmod -R u+x Scripts/*.sh
FROM ubuntu:22.04

WORKDIR /
# Set defaults for environment variables
ENV TZ=America/Chicago
ENV VNC_PASSWORD=1234
ENV TWS_MAJOR_VRSN=${IB_GATEWAY_INSTVER}
ENV IBC_INI=/opt/IBController/IBController.ini
ENV IBC_PATH=/opt/IBController
ENV TWS_PATH=/root/Jts
ENV TWS_CONFIG_PATH=/root/Jts
ENV SOCAT_LISTEN_PORT=5003
ENV SOCAT_DEST_PORT=4003
ENV SOCAT_DEST_ADDR=127.0.0.1
ENV HEALTHCHECK_CLIENTID=990
ENV HEALTHCHECK_LISTEN_PORT=4002
ENV HEALTHCHECK_IP=127.0.0.1
ENV IBAPI_VERSION=1030.01
ENV USER=root

LABEL maintainer="forhire"

ARG DEBIAN_FRONTEND=noninteractive
ARG IB_GATEWAY_VERSION=stable-standalone
ARG IB_CONTROLLER_VERSION=3.22.0
ARG IB_GATEWAY_INSTVER=stable-standalone

# Install TWS
RUN yes n | /opt/TWS/ibgateway-latest-standalone-linux-x64-v974.4g.sh
# https://github.com/IbcAlpha/IBC/releases/download/3.19.0/IBCLinux-3.19.0.zip

# Install necessary packages
RUN set -x && apt-get update && \
apt-get install -y wget unzip xvfb libxtst6 libxrender1 libxi6 xinit \
x11vnc tightvncserver socat software-properties-common iproute2 ncat python3-pip \
xfonts-base \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
xinit \
&& rm -rf /var/lib/apt/lists/*
# https://download2.interactivebrokers.com/installers/ibgateway/latest-standalone/ibgateway-latest-standalone-linux-x64.sh
# Setup IB TWS and IBController
RUN set -x && \
mkdir -p /opt/TWS && \
cd /opt/TWS && \
wget https://download2.interactivebrokers.com/installers/ibgateway/${IB_GATEWAY_VERSION}/ibgateway-${IB_GATEWAY_VERSION}-linux-x64.sh && \
chmod a+x ibgateway-${IB_GATEWAY_VERSION}-linux-x64.sh && \
mkdir -p /opt/TWS/twsapi && \
cd /opt/TWS/twsapi && \
wget https://interactivebrokers.github.io/downloads/twsapi_macunix.${IBAPI_VERSION}.zip && \
unzip twsapi_macunix.${IBAPI_VERSION}.zip && \
cd IBJts/source/pythonclient && \
python3 -m pip install wheel && \
python3 setup.py bdist_wheel && \
WHLFILE=`find . -name '*.whl' -type f` && \
python3 -m pip install --user --upgrade ${WHLFILE} && \
cd /opt/TWS && \
rm twsapi/twsapi_macunix.${IBAPI_VERSION}.zip && \
printf "/root/Jts/ibgateway/${IB_GATEWAY_INSTVER}\n\n" | ./ibgateway-${IB_GATEWAY_VERSION}-linux-x64.sh && \
rm ibgateway-${IB_GATEWAY_VERSION}-linux-x64.sh && \
mkdir -p /opt/IBController/Logs && \
cd /opt/IBController/ && \
wget -q https://github.com/IbcAlpha/IBC/releases/download/${IB_CONTROLLER_VERSION}/IBCLinux-${IB_CONTROLLER_VERSION}.zip && \
unzip IBCLinux-${IB_CONTROLLER_VERSION}.zip && \
rm IBCLinux-${IB_CONTROLLER_VERSION}.zip && \
chmod -R u+x ./*.sh ./scripts/*.sh

WORKDIR /

# Set display environment variable
ENV DISPLAY :0

ADD runscript.sh runscript.sh
ADD ./vnc/xvfb_init /etc/init.d/xvfb
ADD ./vnc/vnc_init /etc/init.d/vnc
ADD ./vnc/xvfb-daemon-run /usr/bin/xvfb-daemon-run
COPY runscript.sh /
COPY healthcheck.py /
COPY vnc/xvfb_init /etc/init.d/xvfb
COPY vnc/vnc_init /etc/init.d/vnc
COPY vnc/xvfb-daemon-run /usr/bin/xvfb-daemon-run

RUN chmod -R u+x runscript.sh \
&& chmod -R 777 /usr/bin/xvfb-daemon-run \
&& chmod 777 /etc/init.d/xvfb \
&& chmod 777 /etc/init.d/vnc
USER root

RUN dos2unix /usr/bin/xvfb-daemon-run \
&& dos2unix /etc/init.d/xvfb \
&& dos2unix /etc/init.d/vnc \
&& dos2unix runscript.sh
RUN chmod -R u+x /runscript.sh && \
chmod -R 755 /usr/bin/xvfb-daemon-run && \
chmod 755 /etc/init.d/xvfb && \
chmod 755 /etc/init.d/vnc

#USER nobody

# Below files copied during build to enable operation without volume mount
COPY ./ib/IBController.ini /root/IBController/IBController.ini
COPY ./ib/jts.ini /root/Jts/jts.ini
COPY ib/IBController.ini /opt/IBController/IBController.ini

HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD /healthcheck.py -a ${HEALTHCHECK_IP} -p ${HEALTHCHECK_LISTEN_PORT} -c ${HEALTHCHECK_CLIENTID} -r 1

# Expose VNC port
EXPOSE 5900

# Expose IB Gateway API port
EXPOSE ${SOCAT_DEST_PORT}

# Expose API port
EXPOSE ${SOCAT_LISTEN_PORT}

CMD bash runscript.sh
CMD /bin/bash runscript.sh
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Interactive Brokers Gateway Docker

IB Gateway running in Docker with [IB Controller](https://github.com/ib-controller/ib-controller/) and VNC
IB Gateway running in Docker with [IBC](https://github.com/IbcAlpha/IBC/) and VNC

* TWS Gateway: v974.4g
* IB Controller: v3.2.0
* TWS Gateway: 10.30.01
* IBC: 3.22.0

### Docker Hub image
### Docker container image

* https://hub.docker.com/r/mvberg/ib-gateway-docker
* ghcr.io/forhire/ib-gateway-docker/ib-gateway-docker:VERSIONTAG

### HELM3 chart for deploying to Kubernetes
* https://github.com/forhire/ibgw

### Getting Started

Expand Down Expand Up @@ -55,14 +58,6 @@ Please do not open your box to the internet.

![vnc](docs/ib_gateway_vnc.jpg)

### Demo Accounts

It seems that all of the `demo` accounts are dead for good:

* edemo
* fdemo
* pmdemo

### Troubleshooting

Sometimes, when running in non-daemon mode, you will see this:
Expand Down
33 changes: 24 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
version: '2'
version: '3'
services:
tws:
image: ib-gateway-docker_tws:latest
ports:
- "7496:5003"
- "4001:5003"
- "4002:5003"
- "4003:5003"
- "5902:5900"
build: .
ports:
- "4003:4003"
- "5901:5900"
- "4003:5003"
- "5902:5900"
volumes:
- ./ib/IBController.ini:/root/IBController/IBController.ini
- ./ib/jts.ini:/root/Jts/jts.ini
- ib-controller:/opt/IBController
- ib-jts:/root/Jts
environment:
- TZ=America/Chicago
# Variables pulled from /IBController/IBControllerGatewayStart.sh
- VNC_PASSWORD=1234 # CHANGEME
- TWS_MAJOR_VRSN=974
- IBC_INI=/root/IBController/IBController.ini
- TWS_MAJOR_VRSN=stable-standalone
- IBC_INI=/opt/IBController/IBController.ini
- IBC_PATH=/opt/IBController
- TWS_PATH=/root/Jts
- TWS_CONFIG_PATH=/root/Jts
- LOG_PATH=/opt/IBController/Logs
- JAVA_PATH=/opt/i4j_jres/1.8.0_152/bin # JRE is bundled starting with TWS 952
- JAVA_PATH=/opt/i4j_jres/1.8.0_152-tzdata2019c/bin # JRE is bundled starting with TWS 952
- TRADING_MODE=paper # either paper or live
- TWSUSERID=fdemo # IB account
- TWSPASSWORD=demouser # IB account password
- FIXUSERID=
- FIXPASSWORD=
- APP=GATEWAY
- APP=GATEWAY
- SOCAT_LISTEN_PORT=5003
- SOCAT_DEST_PORT=4003 # paper = 4002, live 4003
- SOCAT_DEST_ADDR=127.0.0.1

volumes:
ib-controller:
ib-jts:

Loading