> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/an-zhuang/setup-docker.md).

# 设置 Docker

Overleaf 运行在 Docker 上。你必须安装：

* Docker 引擎（Docker CE）
* Docker Compose 插件（`docker compose`，v2）

这些步骤适用于较新的 Ubuntu LTS（20.04/22.04/24.04）。

{% hint style="warning" %}
避免安装 `docker.io` 来自 Ubuntu 的默认 apt 仓库。\
请使用 Docker 的官方仓库，这样你就能获得较新的 Docker 版本以及 `docker compose` 插件。
{% endhint %}

官方文档来自： <https://docs.docker.com/engine/install/ubuntu/>.

{% stepper %}
{% step %}

### 1) 删除旧的/冲突的软件包（如果存在）

如果 Docker 之前是从其他来源安装的，请先将其删除：

{% code overflow="wrap" %}

```bash
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)
```

{% endcode %}

如果某些软件包未安装，此命令是安全的。
{% endstep %}

{% step %}

### 2) 添加 Docker 的官方 apt 仓库

安装前置依赖：

```bash
sudo apt update
sudo apt install -y ca-certificates curl
```

添加 Docker GPG 密钥：

{% code overflow="wrap" %}

```bash
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
```

{% endcode %}

添加仓库：

{% code overflow="wrap" %}

```bash
# 将仓库添加到 Apt 源：
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
```

{% endcode %}
{% endstep %}

{% step %}

### 3) 安装 Docker 引擎 + Compose 插件

安装 Docker 和 Compose 插件：

{% code overflow="wrap" %}

```bash
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

{% endcode %}

设置 Docker 开机启动：

```bash
sudo systemctl enable --now docker
```

{% endstep %}

{% step %}

### 4) 验证安装

这些命令应该能够无错误运行：

```bash
docker --version
docker compose version
sudo docker run --rm hello-world
docker ps
```

{% endstep %}

{% step %}

### 5)（可选）无需 sudo 运行 Docker

将你的用户添加到 `docker` 组：

```bash
sudo usermod -aG docker $USER
```

然后 **注销并重新登录**，或者运行：

```bash
newgrp docker
```

现在这应该可以在不使用 `sudo`:

```bash
docker ps
```

{% hint style="danger" %}
的情况下工作 `docker` 该组在主机上拥有与 root 等同的访问权限。\
对于典型的 Overleaf 安装，这是预期行为，尤其是在你启用 Sandboxed Compiles 时更为相关。
{% endhint %}
{% endstep %}
{% endstepper %}

### 下一步

一旦 Docker 可用，请继续进行以下 Toolkit 安装步骤： [使用 Toolkit](/on-premises/zh-cn/an-zhuang/using-the-toolkit.md).


---

# 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://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/an-zhuang/setup-docker.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.
