2

I'm new to docker and I'm trying to run h2o in docker and then use python to connect to it. I have folder with: model-generator folder in which I have the python script and Dockerfile to build an image h2o-start folder in which I have h2o.jar file and Dockerfile to start that jar docker-compose.yml file with:

version: "3"
services:
   h2o-start:
      image: milanpanic2/h2o-start
      build: 
         context: ./h2o-start
      restart: always
   model-generator:
      image: milanpanic2/model-generator
      build:
         context: ./model-generator
      restart: always

My python script contains:

import h2o   

h2o.connect(ip='172.19.0.3', port='54321')

When I run docker-compose up it gives me an error that python can't connect, because there isn't anything on 172.19.0.3

Dockerfile for python

FROM python:2.7-slim
WORKDIR /app
ADD . /app
RUN pip install > --trusted-host pypi.python.org -r requirements.txt 
EXPOSE 80 
ENV NAME World 
CMD ["python", "passhash.py"]

Dockerfile for h2o

FROM openjdk:8
ADD h2o.jar h2o.jar
EXPOSE 54321 EXPOSE 54322
ENTRYPOINT ["java", "-jar", "h2o.jar"]
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
Milan Panic
  • 473
  • 1
  • 9
  • 30
  • Possible duplicate of [How to connect to docker container from localhost](https://stackoverflow.com/questions/48931857/how-to-connect-to-docker-container-from-localhost) – David Maze Jul 03 '18 at 09:49

1 Answers1

2

Try to start container exposing port 54321: add to your h2o-start: in docker-compose file:

ports: 
  - "54321:54321"
  - "54322:54322"
Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42