> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/on-premises/vi/bat-dau/requirements/setup-docker.md).

# Thiết lập Docker

Overleaf chạy trên Docker. Bạn phải cài đặt:

* Docker Engine (Docker CE)
* Docker Compose **plugin** (`docker compose`, v2)

Các bước này dành cho một bản Ubuntu LTS gần đây (20.04/22.04/24.04).

{% hint style="warning" %}
Tránh cài đặt `docker.io` từ kho apt mặc định của Ubuntu.\
Hãy dùng kho chính thức của Docker để bạn có được phiên bản Docker mới và `docker compose` plugin.
{% endhint %}

Tài liệu chính thức lấy từ: <https://docs.docker.com/engine/install/ubuntu/>.

{% stepper %}
{% step %}

### 1) Gỡ bỏ các gói cũ/xung đột (nếu có)

Nếu trước đây Docker được cài từ nguồn khác, hãy gỡ nó trước:

{% 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 %}

Lệnh này an toàn ngay cả khi một số gói chưa được cài đặt.
{% endstep %}

{% step %}

### 2) Thêm kho apt chính thức của Docker

Cài đặt các gói phụ thuộc cần thiết:

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

Thêm khóa GPG của Docker:

{% 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 %}

Thêm kho:

{% code overflow="wrap" %}

```bash
# Thêm kho vào nguồn 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) Cài đặt Docker Engine + plugin Compose

Cài đặt Docker và plugin Compose:

{% code overflow="wrap" %}

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

{% endcode %}

Khởi động Docker khi bật máy:

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

{% endstep %}

{% step %}

### 4) Xác minh cài đặt

Các lệnh sau nên chạy mà không có lỗi:

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

{% endstep %}

{% step %}

### 5) (Tùy chọn) Chạy Docker không cần sudo

Thêm người dùng của bạn vào `docker` nhóm:

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

Sau đó **đăng xuất rồi đăng nhập lại**, hoặc chạy:

```bash
newgrp docker
```

Bây giờ lệnh này sẽ hoạt động mà không cần `sudo`:

```bash
docker ps
```

{% hint style="danger" %}
Trường `docker` Nhóm này có quyền tương đương root trên máy chủ.\
Điều này là bình thường đối với các cài đặt Overleaf điển hình, và đặc biệt quan trọng nếu bạn bật Sandboxed Compiles.
{% endhint %}
{% endstep %}
{% endstepper %}

### Bước tiếp theo

Khi Docker đã hoạt động, hãy tiếp tục các bước cài đặt Toolkit trong [Sử dụng Toolkit](/on-premises/vi/cai-dat/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://overleaf-pro.ayaka.space/on-premises/vi/bat-dau/requirements/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.
