Bart, you wrote as problem description as "repeatedly starting TWS/Gateway, logging in successfully, and then restarting after a short time". In the past I have had that issue myself, without using Docker or something similar. I then asked IBKR for their advice. They mentioned to me that after stopping TWS/Gateway (or after a crash) you should give IBKR's servers some time for their housekeeping. It takes time for them to recognize that the client ID is no longer active. And then the server needs to "clean up". If you restart your software too quickly this clean up is not yet completed. The server will then think that your client ID is still in use, resulting in the error message you received. As far as I know are there two solutions to this issue: either wait long enough (IBKR suggested a couple of minutes) before restarting. Or restart using a new client ID, not identical to the previous one.