I have an app in Python that I want to run in a Docker container and it has a line:
h2o.connect(ip='127.0.0.1', port='54321')
The h2o server is running in a Docker container and it always has a different IP. One time it was started on 172.19.0.5, the other time 172.19.0.3, sometimes 172.17.0.3. So it is always random, and I can't connect the Python app. I tried to expose the port of h2o server to localhost and then connect the Python (the code above), but it is not working.
You dont connect two docker containers though ip addresses. Instead, you want to use docker internal network aliases:
version: '3'
services:
server:
...
depends_on:
- database
database:
...
expose:
- 54321:54321
then you can define your connectio in server as:
h2o.connect(ip='127.0.0.1', port='54321')