DockerTeX 和 DockerTeXstudio 是一系列提供完整 LaTeX 环境的 Docker 镜像,支持多种 TeX Live 版本和 TeXstudio GUI。这些镜像基于 Debian 和 Ubuntu 构建,旨在为 LaTeX 文档开发提供一致、隔离且功能完备的环境,适用于从命令行编译到 GUI 编辑的各种使用场景。
| 镜像名称 | 架构 | 描述 |
|---|---|---|
| raabf/latex-versions | x86_64 | 命令行 LaTeX 环境 |
| raabf/latex-versions-arm | ARM | ARM 架构的命令行 LaTeX 环境 |
| raabf/texstudio-versions | x86_64 | 包含 TeXstudio GUI 的 LaTeX 环境 |
当 Debian 或 Ubuntu 基础镜像更新时(平均每月一次),所有镜像都会在 Dockerhub 上自动重建。
可通过 TeX Live 版本标签(如 texlive2016)或发行版代号(如 stretch)指定所需版本:
| TeX Live 版本 | Docker 标签 | 基础发行版 | 备注 |
|---|---|---|---|
| v2012 | texlive2012 | Debian wheezy | EOL,最后支持的 TeXstudio: 2.12.10-2 |
| v2013 | texlive2013 | Ubuntu trusty | EOL,最后支持的 TeXstudio: 2.12.14-1 |
| v2014 | texlive2014 | Debian jessie | EOL,最后支持的 TeXstudio: 2.12.14-1 |
| v2015 | texlive2015 | Ubuntu xenial | EOL,最后支持的 TeXstudio: 2.12.22-1 |
| v2016 | texlive2016 | Debian stretch | ARM 架构最新标签 |
| v2017 | texlive2017 | Ubuntu bionic | - |
| v2018 | texlive2018 | Debian buster | - |
| v2019 | texlive2019 | Ubuntu focal | - |
| v2020 | texlive2020 | Debian bullseye | - |
| v2021 | texlive2021 | Ubuntu jammy | 最新稳定版 (latest 标签) |
| v2022 | texlive2022 | Debian bookworm | 测试版 (testing 标签),开发中 |
注:EOL 表示该发行版已终止支持,不再接收更新,但镜像仍可正常使用。
bashdockertex [-t|--tag tagname] command
编译当前目录中的 document.tex:
bash# 使用默认标签(texlive2021) dockertex pdftex document.tex # 指定特定版本 dockertex --tag texlive2018 pdflatex document.tex # 使用 Makefile dockertex --tag texlive2019 make all
设置默认标签,避免每次输入 --tag:
bashexport DOCKERTEX_DEFAULT_TAG="texlive2018"
指定容器引擎(默认为 podman,如果已安装,否则为 docker):
bashexport DOCKERTEX_ENGINE="docker"
bashdockertexstudio [-t|--tag tagname] [-v|--volume mapping]* [texstudio options]
启动默认版本的 TeXstudio:
bashdockertexstudio
指定标签和额外卷挂载:
bashdockertexstudio --tag texlive2019 --volume /media/data/tex:/home/user/tex
直接打开特定文件:
bashdockertexstudio --tag texlive2021 document.tex
bashx11docker --network=host --share $HOME raabf/texstudio-versions:texlive2021
设置默认标签:
bashexport DOCKERTEXSTUDIO_DEFAULT_TAG="texlive2020"
指定容器引擎:
bashexport DOCKERTEXSTUDIO_ENGINE="podman"
直接使用 docker 命令运行特定版本的 LaTeX:
bash# 编译单个文件 docker run --rm -v "$PWD":/workdir -u "$(id -u):$(id -g)" raabf/latex-versions:texlive2021 pdflatex document.tex # 启动交互式 bash docker run -it --rm -v "$PWD":/workdir -u "$(id -u):$(id -g)" raabf/latex-versions:texlive2021 bash
运行 TeXstudio GUI:
bashdocker run --rm \ -v "$HOME":/home/user \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e DISPLAY \ -u "$(id -u):$(id -g)" \ --network=host \ raabf/texstudio-versions:texlive2021
创建 docker-compose.yml 文件:
yamlversion: '3' services: latex: image: raabf/latex-versions:texlive2021 volumes: - ./:/workdir user: "${UID}:${GID}" command: pdflatex document.tex texstudio: image: raabf/texstudio-versions:texlive2021 volumes: - "${HOME}:/home/user" - "/tmp/.X11-unix:/tmp/.X11-unix" environment: - DISPLAY user: "${UID}:${GID}" network_mode: "host" command: texstudio
使用方法:
bash# 编译文档 UID=$(id -u) GID=$(id -g) docker-compose run latex # 启动 Texstudio UID=$(id -u) GID=$(id -g) docker-compose run texstudio
推荐使用 zsh 插件管理器安装命令行工具,便于自动更新。
在 ~/.zshrc 中添加:
zshzplug raabf/dockertex, \ from:gitlab, \ hook-build:"./posthook.sh --menu-tag latest --menu-volume /media/ext/=/home/ext/"
安装多个版本的菜单条目:
zshzplug raabf/dockertex, \ from:gitlab, \ hook-build:"./posthook.sh --menu-tag latest; ./posthook.sh --menu-tag texlive2018"
适用于非 zsh 用户:
bash# 基本安装(当前用户) curl [***] | bash -s -- --menu-tag latest # 系统级安装 curl [***] | bash -s -- --system --menu-tag latest # 安装并添加额外卷挂载 curl [***] | bash -s -- --menu-tag latest --menu-volume "/media/data/tex:/home/user/tex" # 仅安装命令行工具,不安装 Texstudio curl [***] | bash -s -- --no-texstudio
查看帮助信息:
bashcurl [***] | bash -s -- --help
bashsudo cp bin/dockertex.sh /usr/local/bin/dockertex sudo cp bin/dockertexstudio.sh /usr/local/bin/dockertexstudio sudo chmod a+x /usr/local/bin/dockertex*
bashsudo cp misc/icons/hicolor/scalable/apps/texstudio.svg /usr/local/share/icons/hicolor/scalable/apps/
bashsudo cp misc/dockertexstudio.desktop /usr/local/share/applications/dockertexstudio.desktop sudo tee -a /usr/local/share/applications/dockertexstudio.desktop << EOF Name=Docker TexStudio (latest) Exec=/usr/local/bin/dockertexstudio --tag latest %F Icon=/usr/local/share/icons/hicolor/scalable/apps/texstudio.svg EOF
创建 .gitlab-ci.yml 文件:
yamlstages: - build build_latest: image: raabf/latex-versions:latest stage: build script: - pdflatex -interaction=nonstopmode document.tex - biber document - pdflatex -interaction=nonstopmode document.tex artifacts: paths: - document.pdf expire_in: 1 week test_texlive2018: image: raabf/latex-versions:texlive2018 stage: build script: - pdflatex -interaction=nonstopmode document.tex - biber document - pdflatex -interaction=nonstopmode document.tex artifacts: paths: - document.pdf expire_in: 1 week
当出现以下错误时:
Authorization required, but no authorization protocol specified
在主机上运行:
bashxhost local:root
如果提示找不到显示,尝试修改 dockertexstudio.sh 中的显示设置:
将 --env='DISPLAY' 替换为 -e DISPLAY=unix$DISPLAY
如果遇到网络相关问题,尝试移除 --network=host 参数,但这可能导致 LanguageTool 等网络功能不可用。
如果上述方法仍有问题,尝试使用 x11docker:
bashx11docker --network=host --share $HOME raabf/texstudio-versions:texlive2021
该项目旨在为大多数 LaTeX 项目提供通用环境。如有任何缺失功能或问题,欢迎贡献。项目仓库和问题跟踪见 GitLab 仓库。
本项目采用 MIT 许可证。
来自真实用户的反馈,见证轩辕镜像的优质服务
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像加速服务
在 Docker Desktop 配置镜像加速
Docker Compose 项目配置加速
Kubernetes 集群配置 Containerd
在宝塔面板一键配置镜像加速
Synology 群晖 NAS 配置加速
飞牛 fnOS 系统配置镜像加速
极空间 NAS 系统配置加速服务
爱快 iKuai 路由系统配置加速
绿联 NAS 系统配置镜像加速
QNAP 威联通 NAS 配置加速
Podman 容器引擎配置加速
HPC 科学计算容器配置加速
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名加速
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429