Closed karypid closed 1 month ago
In fact, docker inspect
confirms that this is the value passed in when creating the container:
> docker inspect c9d0fd40740c | grep Env -A 9
"Env": [
"PASSWORD=myptpass",
"TWOFA_TIMEOUT_ACTION=restart",
"GATEWAY_OR_TWS=tws",
"IBC_TradingMode=paper",
"USERNAME=MY_UNIX_USERNAME", <<<<< !!! (this is wrong)
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"IBC_VERSION=3.20.0",
"INSTALL_FILENAME=ibgateway-10.19.2p-standalone-linux-x64.sh"
],
I am 100% certain I have not mistyped USERNAME in my .env file:
> grep USERNAME .env compose.yml --color
.env:USERNAME='myptuser'
compose.yml: USERNAME: ${USERNAME}
The above output is colored and all 3 instances of USERNAME are highlighted...
I edited start.sh
locally to end as follows:
> cat start.sh | tail -n 5
exec /opt/ibc/scripts/ibcstart.sh "${TWS_MAJOR_VERSION}" $command \
"--user=${IBKRUSER:-}" \
"--pw=${PASSWORD:-}" \
"--on2fatimeout=${TWOFA_TIMEOUT_ACTION:-restart}" \
"--tws-settings-path=${TWS_SETTINGS_PATH:-}"
> > ./build.sh stable 10.19.2p
> cd stable
> docker image build . -t myibkr:latest
....
=> => writing image sha256:743eed2df1ed99f3d3959689744978f8eaf268186259ffad15b438f8d405f095 0.0s
=> => naming to docker.io/library/myibkr:latest 0.0s
Then updated the compose file to use my local image and fired up a container with that variable:
> cat .env
IBKRUSER='myptuser'
# wrap password in single quotes if $, /, or \ are present
PASSWORD='myptpass'
> cat compose.yml
---
services:
ibkr:
image: myibkr:latest # latest, stable, 10.21, 10.21.1p etc
ports:
- "127.0.0.1:6080:6080" # noVNC browser access
- "127.0.0.1:8888:8888" # API access
ulimits:
nofile: 10000 # See FAQ
environment:
IBKRUSER: ${IBKRUSER}
PASSWORD: ${PASSWORD}
TWOFA_TIMEOUT_ACTION: restart
GATEWAY_OR_TWS: tws
# Variables prefixed with IBC_ override IBCAlpha`s config.ini:
IBC_TradingMode: paper
# IBC_ReadOnlyApi: yes
> docker compose up
...
This worked perfectly fine for me. I think the problem is that USERNAME
is defined in my environment (maybe because I use fish
for my shell?):
> env | grep USERNAME
myunixusername
I guess when the variable is set, then it overrides the .env
content. This fixes it for me:
USERNAME=MYPTUSERNAME docker compose up
If anyone else comes across this, hope this helps...
P.S. it might be a good idea to rename the variables to IBKRUSER / IBKRPASS as these generic names might clash for random environments (like mine).
Hello,
When I launch the container directly with docker, it works fine:
With the above I can connect to Xvnc and TWS is running and logged in (with paper trading mode).
When I use this however, I cannot login due to the username being filled in being my actual username:
Running
docker compose up
gives:But when I connect to Xvnc, I see the login dialog with username filled in being wrong. It is filled in with my actual LINUX user account (what I get when I run
whoami
) instead of the value in.env
. As a result login fails. If I edit the username to replace it withmyptuser
and press the Login button, then TWS logs in normally (so the password filled in is correct).I looked at
start.sh
and see that in the end it runs:I entered the running container (which failed to login) and found:
So indeed the environment variable has not taken effect when bringing up with
docker compose up
.I'm not sure what to make of this. Anyone else experiencing the same?