> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 0. 安装 Docker

> 在 Ubuntu 上安装 Docker Engine 和 Compose 插件，用于部署 Overleaf。

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

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

以下步骤适用于较新的 Ubuntu LTS 版本（20.04/22.04/24.04）。

> [!WARNING]
>
> 避免从 Ubuntu 默认的 apt 仓库安装 `docker.io`。\
> 请使用 Docker 官方仓库，以获得较新的 Docker 版本和 `docker compose` 插件。

官方文档来源：[https://docs.docker.com/engine/install/ubuntu/](https://docs.docker.com/engine/install/ubuntu/)。

**1. 1) 移除旧的/冲突的软件包（如有）**

如果之前从其他来源安装过 Docker，请先将其移除：

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

即使部分软件包未安装，此命令也可以安全运行。

**2. 2) 添加 Docker 官方 apt 仓库**

安装前置依赖：

```bash theme={null}
sudo apt update
sudo apt install -y ca-certificates curl
```

添加 Docker GPG 密钥：

```bash wrap theme={null}
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
```

添加仓库：

```bash wrap theme={null}
# Add the repository to Apt sources:
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
```

**3. 3) 安装 Docker Engine + Compose 插件**

安装 Docker 和 Compose 插件：

```bash wrap theme={null}
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

设置 Docker 开机自启：

```bash theme={null}
sudo systemctl enable --now docker
```

**4. 4) 验证安装**

以下命令应能正常运行且不报错：

```bash theme={null}
docker --version
docker compose version
sudo docker run --rm hello-world
docker ps
```

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

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

```bash theme={null}
sudo usermod -aG docker $USER
```

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

```bash theme={null}
newgrp docker
```

现在无需 `sudo` 也应能运行：

```bash theme={null}
docker ps
```

> [!CAUTION]
>
> `docker` 组在主机上拥有等同于 root 的访问权限。\
> 这对于典型的 Overleaf 安装来说是预期行为，尤其是在启用沙盒编译时更是如此。

### 下一步

Docker 正常运行后，请继续阅读 [1. 下载 Toolkit](https://ayakaleaf-pro.mintlify.site/zh-CN/on-premises/installation/using-the-toolkit/1.-download-the-toolkit.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.