Install LibreTranslate Inside Docker Container in Linux

Install LibreTranslate Inside Docker Container in Linux

LibreTranslate is a translation web service that support various languages. It doesn't use external providers such as Google to perform translations. LibreTranslate is based on the open-source Argos Translate library.

This tutorial explains how to install LibreTranslate inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install LibreTranslate

Before starting, create directories for data and cache:

sudo mkdir -p /opt/libretranslate/{data,cache}

Set user, which ID is 1032 as owner for newly created directories:

sudo chown -R 1032:1032 /opt/libretranslate

Note: it doesn't matter that user (ID: 1032) doesn't exist on host system. This user will be created in the container.

  • Host network

Run the following command to create a container for LibreTranslate that uses host network:

docker run -d --name=libretranslate --restart=always --network=host \
    -e LT_LOAD_ONLY=de,en \
    -v /opt/libretranslate/data:/home/libretranslate/.local/share \
    -v /opt/libretranslate/cache:/home/libretranslate/.local/cache \
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, LibreTranslate service is listening on port 5000. It can be changed with -p option.

docker network create app-net
docker run -d --name=libretranslate --restart=always --network=app-net \
    -p 8080:5000 \
    -e LT_LOAD_ONLY=de,en \
    -v /opt/libretranslate/data:/home/libretranslate/.local/share \
    -v /opt/libretranslate/cache:/home/libretranslate/.local/cache \

Note: It might take a while before initialization is finished and the Docker container starts to respond to requests. It can take a lot of time to download the language models. So, recommended specifying only required languages using LT_LOAD_ONLY.

Testing LibreTranslate

To access a web interface, open a web browser and go to http://<IP_ADDRESS>:5000, where <IP_ADDRESS> is the IP address of the system.

LibreTranslate Inside Docker Container in Linux

Uninstall LibreTranslate

To completely remove LibreTranslate, remove its container:

docker rm --force libretranslate

Remove LibreTranslate image:

docker rmi libretranslate/libretranslate

You can also remove LibreTranslate data and cache:

sudo rm -rf /opt/libretranslate

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.