> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/texlive/zh-tw/docker-zhong-de-texlive.md).

# Docker 中的 TeXLive

### Docker

Docker 提供了一種輕量且可攜的方式，可在隔離的容器中封裝並執行應用程式。透過將應用程式與所有必要的相依套件一起打包，容器可確保在不同機器上都能有一致的行為，從筆電到正式環境伺服器皆然。

TeX Live 功能強大，但體積龐大，而且對系統層級的差異很敏感。將 TeX Live 封裝到 Docker 映像檔中，可讓 LaTeX 工具鏈變得可預測、可重現，並且容易分發。

然而，有些 TeX Live 套件會依賴 shell 存取。基於安全考量，容器應在受限環境中執行，以防止使用者執行任意 shell 指令（例如透過 `\write18` 或 shell escape）。這種隔離可保護主機系統，並避免對容器底層檔案系統或像是 `bash`.

### TeXLive 完整版

[TeXLive-Full@ayaka-notes](https://github.com/ayaka-notes/texlive-full/) 是一個功能完整的 **TeXLive Docker 映像檔** 專為 Overleaf Server Pro、Overleaf Pro，以及獨立的 LaTeX 編譯環境（如 CI 或管線）所設計。

此映像檔旨在提供一個幾乎完整的 TeXLive 發行版，並預先安裝常見字型與工具，以將因缺少套件或字型而導致的編譯失敗降到最低。

特色：

* 🚀 同時支援 x86\_64 與 arm64 伺服器架構
* 📦 完整且最佳化的 TeXLive 安裝
* 🧩 預先安裝常見字型與工具
* 🐳 可直接搭配 Docker 與 Docker Compose 使用
* 🧪 已在 Overleaf Server Pro / Overleaf Pro 上測試
* 🔄 定期更新至最新的 TeXLive 發行版
* 🏷 多個 TeXLive 版本標籤（2020 – 最新）
* 🧑‍🔬 支援在 LaTeX 文件中使用 R 程式碼的 Knitr

### Overleaf Pro 使用方式

[TeXLive-Full@ayaka-notes](https://github.com/ayaka-notes/texlive-full/) 支援 **Overleaf Pro**，你可以使用下列環境變數來 `config/variables.env` 檔案，如果你是 [toolkit 使用者](https://github.com/overleaf/toolkit).

例如：

{% code title="config/variables.env" overflow="wrap" %}

```dotenv
ALL_TEX_LIVE_DOCKER_IMAGES=ghcr.io/ayaka-notes/texlive-full:2025.1, ghcr.io/ayaka-notes/texlive-full:2024.1
ALL_TEX_LIVE_DOCKER_IMAGE_NAMES=Texlive 2025, Texlive 2024
TEX_LIVE_DOCKER_IMAGE=ghcr.io/ayaka-notes/texlive-full:2025.1
```

{% endcode %}

### TeXLive 版本

多虧 GitHub Actions，我們可以平行建置所有 tex 映像檔，其中包括：

* `ghcr.io/ayaka-notes/texlive-full:2026.1` （另有 `latest` 標籤）
* `ghcr.io/ayaka-notes/texlive-full:2025.1`
* `ghcr.io/ayaka-notes/texlive-full:2024.1`
* `ghcr.io/ayaka-notes/texlive-full:2023.1`
* `ghcr.io/ayaka-notes/texlive-full:2022.1`
* `ghcr.io/ayaka-notes/texlive-full:2021.1`
* `ghcr.io/ayaka-notes/texlive-full:2020.1`
* `ghcr.io/ayaka-notes/texlive-full:base`

我們使用來自 [texlive 資訊](https://texlive.info/tlnet-archive/)的鏡像存檔，其中包含幾乎所有從 1996 到 2026 的 texlive 映像檔。多虧 Overleaf 的 Dockerfile，我們可以更快地建置這個專案。

> 為什麼不支援 texlive 2019 及更早版本？
>
> 維護這類映像檔遠比想像中困難。我們也認為你可能已經不再使用它們了，因為它們實在太舊了。如果你有需要，請開一個 issue 告訴我。

### 內含元件

下列套件包含於 Docker 映像檔中。

* 所有 TeXLive 套件（該年份）
* R 套件（僅選取部分）
* fontconfig inkscape pandoc python3-pygments wget python3
* gnupg gnuplot perl-modules perl ca-certificates
* ghostscript qpdf r-base-core tar

下列字型包含於 Docker 映像檔中。

* [Google 字型](https://fonts.google.com/)
* [Microsoft msttcorefonts](https://packages.ubuntu.com/jammy/ttf-mscorefonts-installer)
* [Overleaf 支援的字型](https://www.overleaf.com/learn/latex/Questions/Which_OTF_or_TTF_fonts_are_supported_via_fontspec%3F)

{% hint style="warning" %}
請確認相關字型是否可用於商業用途。我們對於 **不負責** 因你不當使用字型而產生的任何法律問題。當你下載映像檔後，即表示你自動同意此條款。
{% endhint %}

### 授權

MIT

### 問題

<details>

<summary>問題 01：字型快取未命中問題</summary>

當 Overleaf 編譯 LaTeX 專案時，如果發生字型缺失， **你可能會發現編譯過程花費很長時間**，那是因為當字型缺失時，TeXLive 會嘗試 **重新建立整個字型快取**。這是一個非常耗時的過程。

在我們的映像檔中，我們已預先建立字型快取，我們透過 [這個 commit](https://github.com/ayaka-notes/texlive-full/commit/0cb66b0dc8b82be628cf6999cfd659d9784e132f)

</details>

<details>

<summary>問題 02：Sync TeX 極度緩慢</summary>

當你在 ShareLaTeX 中使用這個映像檔時，你可能會發現 Sync TeX 非常慢。

請見： <https://github.com/overleaf/overleaf/issues/1150>，只要停用 HTTP 2.0 即可。

</details>

<details>

<summary>問題 03：使用官方 Texlive 映像檔重新編譯時發生錯誤</summary>

如果你在 Docker Hub 上使用 texlive 官方映像檔 `texlive/texlive`，你可能會發現當你重新編譯專案時會報錯。不過，在我們的映像檔中，這個問題已經修復。因為我們使用最新的 Ubuntu 基礎映像檔，並從 Ubuntu 官方套件庫安裝所有相依套件。

</details>

### 其他技術提醒

在建立 TeXLive 映像檔（2019 年以前）時，你可能需要注意下列問題：

* 僅 `http`/`ftp` 在 texlive 2017 之前才受支援，因此你不能使用 `https` 來下載，除非你修改 `peal` 腳本。
* 2015 年以前只提供 sha256 檔案，因此你無法使用 sha512 來驗證。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/texlive/zh-tw/docker-zhong-de-texlive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
