
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
DockerTeX 和 DockerTeXstudio 是一系列提供完整 LaTeX 环境的 Docker 镜像,支持多种 TeX Live 版本和 TeXstudio GUI。这些镜像基于 Debian 和 Ubuntu 构建,旨在为 LaTeX 文档开发提供一致、隔离且功能完备的环境,适用于从命令行编译到 GUI 编辑的各种使用场景。
| 镜像名称 | 架构 | 描述 |
|---|---|---|
| https://hub.docker.com/r/raabf/latex-versions | x86_64 | 命令行 LaTeX 环境 |
| https://hub.docker.com/r/raabf/latex-versions-arm | ARM | ARM 架构的命令行 LaTeX 环境 |
| https://hub.docker.com/r/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
使用 x11docker 运行(增强安全性)
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)" docker.xuanyuan.run/raabf/latex-versions:texlive2021 pdflatex document.tex # 启动交互式 bash docker run -it --rm -v "$PWD":/workdir -u "$(id -u):$(id -g)" docker.xuanyuan.run/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 \ docker.xuanyuan.run/raabf/texstudio-versions:texlive2021
创建 docker-compose.yml 文件:
yamlversion: '3' services: latex: image: docker.xuanyuan.run/raabf/latex-versions:texlive2021 volumes: - ./:/workdir user: "${UID}:${GID}" command: pdflatex document.tex texstudio: image: docker.xuanyuan.run/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 插件管理器安装命令行工具,便于自动更新。
zplug 配置
在 ~/.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 https://gitlab.com/raabf/dockertex/raw/master/install.sh | bash -s -- --menu-tag latest # 系统级安装 curl https://gitlab.com/raabf/dockertex/raw/master/install.sh | bash -s -- --system --menu-tag latest # 安装并添加额外卷挂载 curl https://gitlab.com/raabf/dockertex/raw/master/install.sh | bash -s -- --menu-tag latest --menu-volume "/media/data/tex:/home/user/tex" # 仅安装命令行工具,不安装 Texstudio curl https://gitlab.com/raabf/dockertex/raw/master/install.sh | bash -s -- --no-texstudio
查看帮助信息:
bashcurl https://gitlab.com/raabf/dockertex/raw/master/install.sh | 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: docker.xuanyuan.run/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: docker.xuanyuan.run/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 项目提供通用环境。如有任何缺失功能或问题,欢迎贡献。项目仓库和问题跟踪见 https://gitlab.com/raabf/dockertex/%E3%80%82
本项目采用 https://gitlab.com/raabf/dockertex/blob/master/LICENSE%E3%80%82
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务