Having issues deploying with Docker Compose

I have this in my docker-compose.yml file

# ...
    container_name: libretranslate
    image: libretranslate/libretranslate:latest
    restart: unless-stopped
      - "5000:5000"
    command: --api-keys --disable-web-ui --req-limit 0
     - LT_API_KEYS_DB_PATH=/app/db/api_keys.db # Same result as `db/api_keys.db` or `./db/api_keys.db`
     - libretranslate_api_keys:/app/db/api_keys.db


This is identical to the default compose other than the build is now just the latest image.

When I try to use ./venv/bin/ltmanage keys I get this error:

Traceback (most recent call last):
  File "/app/./venv/bin/ltmanage", line 8, in <module>
  File "/app/venv/lib/python3.10/site-packages/libretranslate/manage.py", line 44, in manage
    db = Database(args.api_keys_db_path)
  File "/app/venv/lib/python3.10/site-packages/libretranslate/api_keys.py", line 30, in __init__
    self.c = sqlite3.connect(db_path, check_same_thread=False)
sqlite3.OperationalError: unable to open database file

This is the db folder:

libretranslate@943cc1b0e7b4:/app$ ls -al db
total 16
drwxr-xr-x 1 libretranslate libretranslate 4096 Nov 18 01:08 .
drwxr-xr-x 1 libretranslate libretranslate 4096 Nov 16 20:52 ..
-rw-r--r-- 1 libretranslate libretranslate    0 Nov 16 20:52 .gitignore
drwxr-xr-x 2 libretranslate libretranslate 4096 Nov 18 01:00 api_keys.db

What am I doing wrong? I’ve read pretty much every other thread that mentions any of the key words from above, but I haven’t found any answers.

Thanks for your help!

So I copied an api_keys.db from a different environment which gave me a workaround. Still annoying

Now when trying to connect to the service from my python service (in the same docker-compose) by using http://libretranslate:5000/translate in my POST request, I’m getting this error:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host libretranslate:5000 ssl:default [Connect call failed ('', 5000)]

This one looks suspicious; I’m not sure you can use a named volume to map a single file?

Try mapping to the entire db folder instead.

1 Like