How to fix libretranslate docker PermissionError: [Errno 13] Permission denied: '/home/libretranslate/.local/share/argos-translate'
Problem
When running the LibreTranslate Docker container, you see the following error:
Traceback (most recent call last):
File "/app/./venv/bin/libretranslate", line 5, in <module>
from libretranslate.main import main
File "/app/venv/lib/python3.11/site-packages/libretranslate/__init__.py", line 2, in <module>
from .main import main
File "/app/venv/lib/python3.11/site-packages/libretranslate/main.py", line 5, in <module>
from libretranslate.app import create_app
File "/app/venv/lib/python3.11/site-packages/libretranslate/app.py", line 12, in <module>
import argostranslatefiles
File "/app/venv/lib/python3.11/site-packages/argostranslatefiles/__init__.py", line 1, in <module>
from argostranslatefiles.argostranslatefiles import *
File "/app/venv/lib/python3.11/site-packages/argostranslatefiles/argostranslatefiles.py", line 1, in <module>
from argostranslate.translate import ITranslation
File "/app/venv/lib/python3.11/site-packages/argostranslate/translate.py", line 10, in <module>
from argostranslate import apis, fewshot, package, sbd, settings
File "/app/venv/lib/python3.11/site-packages/argostranslate/package.py", line 13, in <module>
from argostranslate import networking, settings
File "/app/venv/lib/python3.11/site-packages/argostranslate/networking.py", line 6, in <module>
from argostranslate.utils import error, info
File "/app/venv/lib/python3.11/site-packages/argostranslate/utils.py", line 4, in <module>
from argostranslate import settings
File "/app/venv/lib/python3.11/site-packages/argostranslate/settings.py", line 19, in <module>
os.makedirs(data_dir, exist_ok=True)
File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/home/libretranslate/.local/share/argos-translate'
Solution
The issue here is that you’re mounting directories from the host system into the Docker container, and the user inside the container does not have permission to write to those directories.
In order to fix this, assuming the following configuration:
services:
libretranslate:
image: libretranslate/libretranslate
container_name: libretranslate
ports:
- "5000:5000"
volumes:
- ./libretranslate_data:/home/libretranslate/.local/share
- ./libretranslate_cache:/home/libretranslate/.local/cache
create the directories and set the permissions on the host system:
mkdir -p ./libretranslate_data ./libretranslate_cache
sudo chown -R 1032:nogroup ./libretranslate_data ./libretranslate_cache
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow