Connect 2 Docker images for label-studio

279 Views Asked by At

I'm on Windows, I try to run label-studio on a docker-img and enable automatic annotations with a tesseract machine learning model provided from label-studio-ml-backend on another docker-img. (I'm discovering docker these days...)

Set up:

So far I was able to launch a docker with label-studio, and a docker with tesseract:

# Run the label-studio
docker run --name lbl-studio -it -p 8080:8080 -v label-studio-data:/label-studio/data/ heartexlabs/label-studio:latest label-studio

# DL and run tesseract image
git clone https://github.com/heartexlabs/label-studio-ml-backend
cd label-studio-ml-backend/label_studio_ml/examples/tesseract/
docker-compose up

At this point I have 2 images running on docker (or 3/4, I don't really know how to interpret the 'tesseract' image)

images running

Network:

Here are some network info I could gather, I don't know how bas is the fact that lbl-studio is on 172.17 and the two others on 172.18... This is the result of docker network ls

# Get ips of images 
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' server # 172.18.0.3
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' redis  # 172.18.0.2
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' lbl-studio  # 172.17.0.2
# server: 172.18.0.3
# redis: 172.18.0.2
# lbl-studio: 172.17.0.2

so far redis can ping server but can't ping lbl-studio

Problem:

But, when I go to http://127.0.0.1:8080/, create a project, and try to link the machine learning wizard (http://127.0.0.1:8080/projects/1/settings/ml > add model), I'm not able to connect the tesseract server to the lbl-studio.

The urls I tried to connect are:

Going Further:

I tried to dig deepper and ping the server from lbl-studio, but nothing happened

docker exec -it --user root lbl-studio /bin/bash
apt update
apt install iputils-ping
ping 127.18.0.3  # Nothing happening: 100% packet loss ;)

Question:

How can I connect lbl-studio to the server ?

Thank you for your help :)

2

There are 2 best solutions below

1
On BEST ANSWER

Add lbl-studio to tesseract's docker-compose file as third service. For connect from computer to services use http://127.0.0.1:9090 and http://127.0.0.1:9090. To connect between tesseract and lbl-studio use services name: http://lbl-studio:8080 and http://server:9090. Example:

version: "3.8"

services:
  redis:
    image: redis:alpine
    container_name: redis
    hostname: redis
    volumes:
      - "./data/redis:/data"
    expose:
      - 6379
  server:
    container_name: server
    build: .
    environment:
      - MODEL_DIR=/data/models
      - RQ_QUEUE_NAME=default
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    ports:
      - 9090:9090
    depends_on:
      - redis
    links:
      - redis
    volumes:
      - "./data/server:/data"
      - "./logs:/tmp"

  lbl-studio:
   image: heartexlabs/label-studio:latest
   ports:
    - 8080:8080
   volumes: 
    - label-studio-data:/label-studio/data/

volumes:
  label-studio-data:
2
On

The answer of @artem is perfect, it adds the lbl-studio machine in the tesseract multi-container architecture defined in tesseract-docker-compose file, and adds the shared volume in the end, Terrific !

Another way to achive similar results, that would keep the original structure of the project, is to put the tesseract-multi-container thingy in the bridge network by adding network_mode: bridge in both machines of tesseract in the docker-compose.yml file:

version: "3.8"

services:
  redis:
    image: redis:alpine
    container_name: redis
    hostname: redis
    volumes:
      - "./data/redis:/data"
    expose:
      - 6379
    network_mode: bridge  # <-- here

  server:
    container_name: server
    build: .
    environment:
      - MODEL_DIR=/data/models
      - RQ_QUEUE_NAME=default
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    ports:
      - 9090:9090
    depends_on:
      - redis
    links:
      - redis
    volumes:
      - "./data/server:/data"
      - "./logs:/tmp"
    network_mode: bridge  # <-- and here

Thx for the support