iTranslated by AI
Setting up LaTeX with Docker is faster
1. Introduction
If you are an information engineering student, you have likely experienced the ordeal of installing LaTeX at least once. And no doubt, you have felt despair at how long the installation takes. Spending an entire day on it is not unusual—that is the reality of setting up a LaTeX environment.
In fact, it is well-known that setting up a LaTeX environment can be surprisingly quick if you use Docker. Because of this, I often advocate for using Docker to set up LaTeX. However, there has been one issue: I could not provide quantitative comparison results. Even after searching online, I could not find information comparing the time it takes to build a local installation versus a Docker environment.
Given these circumstances, I decided to actually compare the time required for environment setup. In this article, I measure the time it takes to set up LaTeX on three environments—Windows, Linux, and Docker—using GitHub Actions. The results show that Docker indeed takes the shortest amount of time to set up.
2. Methodology
I decided to compare the time it takes to set up TeX Live in the following three environments:
- Windows local environment
- Linux local environment
- Docker container environment
I decided to use GitHub Actions Runners for the measurement. This decision was based on the ease of ensuring reproducibility, normalizing hardware specs, and the convenience of having the workflow execution time automatically measured. Since GitHub Hosted Runners have high network speeds and relatively lower CPU performance, the conditions are somewhat favorable to Docker.
2.1. Windows local environment
While there are several ways to set up an environment on Windows, I adopted the method of running the network installer via the CLI. While using an ISO image might be faster, I chose this method as it is recommended by the TeX Wiki and represents a more realistic condition. Additionally, I chose the CLI method because using a GUI installer would be difficult to automate in GitHub Actions. As a courtesy, I configured it not to download source code or documentation.
2.2. Linux local environment
For Linux, I adopted the method of performing a full TeX Live installation using apt install texlive-full. I assumed this is the most common method chosen for installing TeX Live on Linux.
2.3. Docker container environment
For Docker, I used the texlive/texlive image. This is the official TeX Live image with a full installation of TeX Live. While I often see articles recommending being24/latex-docker or paperist/texlive-ja for setting up LaTeX environments with Docker, it is safer to use the official image. Regardless of whether it is LaTeX, you should use official images unless there is an exceptional reason not to.
3. Experiment
The GitHub Actions workflow I actually used in the experiment is as follows:
Since I wanted to measure the time it takes to build a LaTeX environment, the measurement for Windows includes downloading the installer. Additionally, to ensure that the LaTeX setup was completed successfully, I ran lualatex --version at the end. I performed the measurement twice. The time taken for each workflow execution was as follows:
| Environment | 1st Trial | 2nd Trial |
|---|---|---|
| Windows | 48m 15s | 46m 13s |
| Linux | 8m 40s | 6m 11s |
| Docker | 1m 28s | 1m 33s |
4. Discussion
The results of the experiment confirmed that Docker takes significantly less time for environment setup. In the case of Windows, it took about 30 times longer than Docker. GitHub Hosted Runner environments have high network speeds and relatively low CPU performance, which is a condition somewhat favorable to Docker. However, I feel that this 30-fold difference is more than enough to justify using it (though I cannot say for sure).
Also, there is a demand for compiling LaTeX on GitHub Actions. In such cases, using Docker is undoubtedly the best approach.
Generally, LaTeX can make your local environment messy, so it is always better to use a container environment if you can.
5. Conclusion
In this article, I compared the time required to set up TeX Live across three environments: Windows, Linux, and Docker, using GitHub Actions. The results show that Docker can complete the environment setup in the shortest amount of time. Now I can carry this data with me to convince others that I recommend using Docker!
Repository
The repository used for the measurement is here:
Discussion