> For the complete documentation index, see [llms.txt](https://moekiwisama-1.gitbook.io/minecraft-docker/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://moekiwisama-1.gitbook.io/minecraft-docker/ru-he-an-zhuang-docker.md).

# 如何安装 Docker

首先你需要有一台干净的 Linux 服务器，这里以 Ubuntu 20.04 为例，不完全一定要是 20.04，大部分版本的 Ubuntu 都可以，服务器可以是物理机，可以是虚拟机，也可以是网上购买的云服务器。

其他操作系统安装方式见 <https://docs.docker.com/engine/install/>

Ubuntu 也可以看官方的 Docker 教程 <https://docs.docker.com/engine/install/ubuntu/>

### 清理并更新你的机器

我们先更新 apt 并且删除机器上以前安装的，有关 Docker的一切，如果以前没有安装过 Docker，可以只更新 apt

```bash
sudo apt update
sudo apt-get remove docker docker-engine docker.io containerd runc纤维
```

### 为 apt 配置 docker 源

给 apt 配置 docker 源可以使我们通过 apt 包管理器来快速安装docker

```bash
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

### 安装 docker

接下来我们就可以直接通过 apt 来安装 docker了

```
 sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli containerd.io
```

### 配置用户权限

一般用户是没有权限使用 docker 的，我们需要为当前用户添加使用 docker 的权限，这样我们使用 docker 时就可以不添加 sudo 了

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

在将用户添加到组以后，需要重新启动 shell，或者重新启动终端，或者重新连接 SSH，才可以生效，不然之后使用 docker 命令时，依然会出现 permission denied

最后只需要用 systemctl 来启动，并且配置开机自启 docker 守护进程，我们就成功地在这台服务器上安装完了 docker

```bash
sudo systemctl start docker.service
sudo systemctl enable docker.service
```


---

# 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:

```
GET https://moekiwisama-1.gitbook.io/minecraft-docker/ru-he-an-zhuang-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
