Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Swarm "OSError: [Errno 97] Address family not supported by protocol" #602

Open
Francis-Nalta opened this issue Mar 20, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@Francis-Nalta
Copy link

Hello

Trying to run docker image of libretranslate in Docker Swarm environment

The Linux OS (Ubuntu 20.04.02 LTS) have ipv6 disabled

The docker version is :

Client: Docker Engine - Community
 Version:           23.0.1
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        a5ee5b1
 Built:             Thu Feb  9 19:46:56 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.1
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       bc3805a
  Built:            Thu Feb  9 19:46:56 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.16
  GitCommit:        31aa4358a36870b21a992d3ad2bef29e1d693bec
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

When running libreTranslate image from docker hub we get this error :

Updating language models
Found 88 models
Keep 2 models
Loaded support for 2 languages (2 models total)!
Running on http://*:5000
Traceback (most recent call last):
  File "/app/./venv/bin/libretranslate", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.10/site-packages/libretranslate/main.py", line 230, in main
    serve(
  File "/app/venv/lib/python3.10/site-packages/waitress/__init__.py", line 13, in serve
    server = _server(app, **kw)
  File "/app/venv/lib/python3.10/site-packages/waitress/server.py", line 78, in create_server
    last_serv = TcpWSGIServer(
  File "/app/venv/lib/python3.10/site-packages/waitress/server.py", line 237, in __init__
    self.create_socket(self.family, self.socktype)
  File "/app/venv/lib/python3.10/site-packages/waitress/wasyncore.py", line 352, in create_socket
    sock = socket.socket(family, type)
  File "/usr/local/lib/python3.10/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol

We tried different configuration in docker compose file, with same result in any case

  • Tried -LT_HOST=127.0.0.1 to except to force ipv4 'only' bind of the container
  • Tried also (simultaneously or not with above setting ) ports : "127.0.0.1:5000:5000"
    (docker swarm tell 127.0.0.1 ignored in ports value with this ports parameter)

Here is docker-compose.yml file used (base file, without the above settings)

version: '3.7'
services:
  libretranslate-nginx:
    image: libretranslate/libretranslate:latest
    # build:
    #   context: .
    #   dockerfile: docker/Dockerfile
    ports:
      - "5000:5000"
    ## Uncomment this for logging in docker compose logs
    # tty: true
    healthcheck:
      test: ['CMD-SHELL', './venv/bin/python scripts/healthcheck.py']     
    ## Uncomment above command and define your args if necessary
    # command: --ssl --ga-id MY-GA-ID --req-limit 100 --char-limit 500
    ## Uncomment this section and the libretranslate_api_keys volume if you want to backup your API keys
    environment:
    #   - LT_API_KEYS=true
    #   - LT_API_KEYS_DB_PATH=/app/db/api_keys.db # Same result as `db/api_keys.db` or `./db/api_keys.db`
    ## Uncomment these vars and libretranslate_models volume to optimize loading time.
      - LT_UPDATE_MODELS=true
      - LT_LOAD_ONLY=en,fr
    volumes:
      # - libretranslate_api_keys:/app/db
    # Keep the models in a docker volume, to avoid re-downloading on startup
      - libretranslate_models:/home/libretranslate/.local:rw
    
    networks:
      - traefik-public
      - libretranslate-network
    # depends_on:
    #   - mastack-phpfpm
    deploy:
      placement:
        constraints:
          - node.labels.production.worker == true
      labels:
          (here comes only traefik config, removed)
volumes:
  # libretranslate_api_keys:
  libretranslate_models:
networks:
  libretranslate-network:
    driver: overlay
    attachable: true
  traefik-public:
    external: true

We also tried to run the container as simple as possible in no swarm context (no docker stack deploy ... ) with same result :
docker run -ti --rm -p 5000:5000 libretranslate/libretranslate --load-only en,fr

Seems the container try to bind to ipv6 even ipv6 not available on the system
We have others docker stacks et containers (elasticsearch, nginx, php-fpm, ...) running perfect on this system in docker swarm mode, with no specific configuration related to ipv6

Can you help ? bug in container initialisation when ipv6 is disabled ?

Francis
Nalta Systems

@github-actions github-actions bot added the enhancement New feature or request label Mar 20, 2024
@pierotofy
Copy link
Member

Maybe related to #596

Perhaps additional logic is required to handle binding to ipv6 correctly.

@Francis-Nalta
Copy link
Author

Just tryed docker images from 1.5.0 to 1.5.5 : All versions run well with same environment, parameters, ... with no error, docker stack running well, container running !

So 1.5.6 (latest) image have different initialisation process that generate the error.
Francis

@Francis-Nalta
Copy link
Author

In this case the host docker have ipv6 disabled, previous versions 1.5.5 and down to 1.5.0 work well, but 1.5.6 exit with then error.

@tjuzdy
Copy link

tjuzdy commented Apr 26, 2024

In this case the host docker have ipv6 disabled, previous versions 1.5.5 and down to 1.5.0 work well, but 1.5.6 exit with then error.

Hello, according to your docker-composer.yml file, which directory on the local machine is language models placed in

@Francis-Nalta
Copy link
Author

@tjuzdy You are right, omitted correct declaration for the volume libretranslate_models
I corrected the declaration to point to a local directory.
(notice docker create a volatil volume as if there is no volume declaration in case volume is not explicitly redirected)

But this volume declaration corrected, this dont change the problem, 1.5.6 stop with the same error,
And previous versions work well (<= 1.5.5) so the problem persist in 1.5.6 with ipv6 disabled on host (and docker)

@Francis-Nalta
Copy link
Author

Just tried 1.5.7 : same error ...

@mskmx
Copy link

mskmx commented May 11, 2024

Try run this:
docker run -ti --rm -p 5000:5000 libretranslate/libretranslate --host 0.0.0.0 --load-only en,fr

Its worked for me in windows ( I modified run.bat ). In my case, its because docker don't support ipv6
https://docs.docker.com/config/daemon/ipv6/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants