Full Tex Live Install

Overleaf provides instructions on how to install a full Tex Live distribution which essentially involves opening a shell within the container and then using tlmgr in order to pull the latest Tex Live distribution within the container.

The problem with that the downloaded files will only live within the container and when the service is stopped, all the downloaded files will simply vanish. Further instructions state that the user should commit the changes to the overleaf image, then perhaps re-tag the image and serve the image from a local repository. Unfortunately, that leads to large images being pulled and pushed on the local network and the inability to upgrade in the future without creating another image.

Looking at the Docker compose file, there is a more practical solution, namely, to bind-mount /usr/local/texlive within the container to a local path on the host machine and then install Tex Live using the official instructions.

The following steps will have to be followed in order to make Tex Live available from a bind mount:

  • start the Docker overleaf container as usual using the Docker compose file,
  • shut down the container,
  • add the mount path provided in this document,
  • start the Docker overleaf container again,
  • check that /usr/local/texlive is now empty,
  • open a shell inside the Docker overleaf container,
  • install Tex Live

Here is a snippet from the Docker compose template provided by overleaf:

version: '3.8'
services:
  overleaf:
    image: sharelatex/sharelatex:latest
    ports:
      - 7643:80
    volumes:
      - /mnt/docker/data/overleaf/default:/var/lib/overleaf
      - /mnt/docker/data/overleaf/texlive:/usr/local/texlive
    environment:

        OVERLEAF_APP_NAME: Overleaf Community Edition

Note that there is a new path added, namely /mnt/docker/data/overleaf/texlive that maps into the container at /usr/local/texlive, which is exactly where Tex Live is expected to be installed. Now, after starting the container again, check that /usr/local/texlive is now empty. If /usr/local/texlive is now empty, issue the following command in order to install Tex Live:

# install Tex Live
cd /tmp && \
    curl -L -o install-tl-unx.tar.gz https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \
    zcat < install-tl-unx.tar.gz | tar xf - && \
    rm *.tar.gz && \
    cd install-tl-* && \
    perl ./install-tl --no-interaction
 
# route symbolic links
INSTALLED_VERSION=$(perl ./install-tl --version | grep -Po '(?<=version )[0-9]*')
CONTAINER_VERSION=$(readlink -f /usr/local/bin/latex | grep -Po '(?<=\/usr\/local\/texlive\/)[0-9]*')
 
[ $INSTALLED_VERSION -eq $CONTAINER_VERSION ] || ln -sf "/usr/local/texlive/$INSTALLED_VERSION" "/usr/local/texlive/$CONTAINER_VERSION"

Once the commands complete, Tex Live will have been installed within the bind-mount path and will exist outside of the image, such that committing the image is no longer necessary. The container can now be stopped and then started again in order to verify that the procedure has been successful.

Using Multiple Networks for Traefik

One of the problems is that the new Overleaf toolkit is not as customizable as one might think at first sight such that running Overleaf by default will create and attach to a custom network named default_overleaf. Traefik, as exemplified in our all-in-one write-up will only bind to a single network such that it will not create a host for Overleaf nor will it proxy any traffic to the container.

A solution is to edit the default toolkit in order to make the Overleaf toolkit bind to multiple networks. For example, for the all-in-one setup binding to the entertainment network should be done such that traefik can pick up the Overleaf container.

The tookit can be modified by editing lib/docker-compose.base.yml and then specifying the networks to bind to, including the network that Docker creates, namely overleaf_default. Here is the modified lib/docker-compose.base.yml:

---
services:

    sharelatex:
        restart: always
        image: "${IMAGE}"
        networks:
          - overleaf_default
          - entertainment
        container_name: sharelatex
        volumes:
            - "${OVERLEAF_DATA_PATH}:${OVERLEAF_IN_CONTAINER_DATA_PATH}"
        ports:
            - "${OVERLEAF_LISTEN_IP:-127.0.0.1}:${OVERLEAF_PORT:-80}:80"
        environment:
          GIT_BRIDGE_ENABLED: "${GIT_BRIDGE_ENABLED}"
          GIT_BRIDGE_HOST: "git-bridge"
          GIT_BRIDGE_PORT: "8000"
          REDIS_HOST: "${REDIS_HOST}"
          REDIS_PORT: "${REDIS_PORT}"
          V1_HISTORY_URL: "http://sharelatex:3100/api"
        env_file:
            - ../config/variables.env
        stop_grace_period: 60s

networks:
    overleaf_default:
        external: true
    entertainment:
        external: true

and with the relevant parts being:

...
        networks:
          - overleaf_default
          - entertainment
...
networks:
    overleaf_default:
        external: true
    entertainment:
        external: true

Note that the networks are specified as "external" otherwise docker compose would complain about these networks being unknown. Specifying a network as "external" just tells docker compose that the network is created manually using external tools such that it should be just left as is without trying to create it.

The example can be expanded in order to include any number of desired networks.


fuss/overleaf.txt ยท Last modified: by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.