> For the complete documentation index, see [llms.txt](https://cube.ewelink.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cube.ewelink.cc/english-th/getting-started/quickstart/docker.md).

# Docker

ติดตั้ง CUBE OS เป็นคอนเทนเนอร์ Docker บนโฮสต์ Linux วิธีนี้ใช้งานได้ดีสำหรับเซิร์ฟเวอร์ที่บ้าน อุปกรณ์ NAS และเครื่อง Linux ที่เปิดตลอดเวลา

{% hint style="info" %}
การติดตั้งใช้งาน Docker รองรับบน **เฉพาะ Linux**.

หากคุณไม่มีโฮสต์ Linux ให้ใช้ [Raspberry Pi](/english-th/getting-started/quickstart/raspberry-pi.md) หรือ [เครื่องเสมือน](/english-th/getting-started/quickstart/virtual-machine/virtualbox.md).
{% endhint %}

### 1. การเตรียมการ

{% stepper %}
{% step %}
**ตรวจสอบสถาปัตยกรรมของโฮสต์**

CUBE Docker รองรับสถาปัตยกรรม Linux เหล่านี้:

* **amd64** (`x86_64`) — พีซี เซิร์ฟเวอร์ Synology NAS และอุปกรณ์ที่คล้ายกัน
* **arm64** (`aarch64`) — Raspberry Pi 4/5, Orange Pi และโฮสต์ ARM อื่นๆ
  {% endstep %}

{% step %}
**ตรวจสอบเวอร์ชันเคอร์เนล Linux**

เคอร์เนล `4.15` หรือใหม่กว่า

```bash
uname -r
```

{% hint style="warning" %}
NAS บางรุ่นมาพร้อมเคอร์เนลเวอร์ชันเก่า เช่น `4.4.x`. โฮสต์เหล่านี้ไม่เข้ากันได้กับ CUBE Docker ในกรณีนั้น ให้รัน CUBE OS ในเครื่องเสมือน Linux แทน
{% endhint %}
{% endstep %}

{% step %}
**ติดตั้ง Docker Engine**

ติดตั้ง Docker Engine บนโฮสต์ก่อนดำเนินการต่อ

ใช้ [คู่มือการติดตั้ง Docker อย่างเป็นทางการ](https://docs.docker.com/engine/install/).
{% endstep %}

{% step %}
**ตรวจสอบพอร์ตที่จำเป็น**

ตรวจสอบให้แน่ใจว่าพอร์ต `80` และ `1883` ว่างอยู่บนโฮสต์

```bash
sudo lsof -i :80
sudo lsof -i :1883
```

* **80** — เว็บ UI ของ CUBE OS
* **1883** — บรอกเกอร์ MQTT

หากมีบริการอื่นใช้งานพอร์ตเหล่านี้ ให้หยุดบริการนั้นก่อน
{% endstep %}

{% step %}
**เตรียมดองเกิล Zigbee หากจำเป็น**

หากคุณวางแผนจะเพิ่มอุปกรณ์ Zigbee ให้เชื่อมต่อดองเกิล Zigbee ที่รองรับเข้ากับโฮสต์

ดองเกิล Zigbee ที่ทดสอบแล้ว ได้แก่:

> SONOFF ZBDongle-MAX\
> SONOFF ZBDongle-PMG24\
> SONOFF ZBDongle-LMG21\
> SONOFF ZBDongle-E\
> SONOFF ZBDongle-P\
> [รายการอื่น ๆ](https://darkxst.github.io/silabs-firmware-builder/) โดยนักพัฒนา @darkxst&#x20;

{% hint style="info" %}
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการกำหนดค่า Zigbee และความเข้ากันได้ โปรดดูที่ [คู่มือ](/english-th/compatibility-check/zigbee.md).
{% endhint %}

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการรองรับ Zigbee โปรดดู [คู่มือนี้](/english-th/compatibility-check/zigbee.md).
{% endstep %}
{% endstepper %}

### 2. ดึงอิมเมจ

{% stepper %}
{% step %}
**ดาวน์โหลดอิมเมจล่าสุด**

```bash
docker pull ghcr.io/ewelinkcube/cube-os:latest
```

<div align="left"><figure><img src="/files/d615852fb0ff04960957199cf10577d1830b6906" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
คุณสามารถแทนที่ `latest` ด้วยแท็กเวอร์ชันเฉพาะ เช่น `2.10.3`. เวอร์ชันที่มีให้ใช้งานแสดงอยู่บน [GitHub Releases](https://github.com/eWeLinkCUBE/CUBE-OS/releases/).
{% endhint %}
{% endstep %}
{% endstepper %}

### 3. เริ่ม CUBE OS

{% stepper %}
{% step %}
**สร้างไดเรกทอรีข้อมูล**

```bash
mkdir -p ~/cubeos-data
```

ไดเรกทอรีนี้ใช้เก็บอุปกรณ์ ฉาก และการตั้งค่าของคุณ
{% endstep %}

{% step %}
**ตรวจสอบพาธของอุปกรณ์ Zigbee หากคุณใช้งานอยู่ (ไม่บังคับ)**

พาธอุปกรณ์ที่พบบ่อยคือ:

```bash
ls /dev/ttyUSB* /dev/ttyACM*
```

ใช้พาธที่ถูกต้องในคำสั่งถัดไป
{% endstep %}

{% step %}
**เริ่มคอนเทนเนอร์**

ใช้คำสั่งนี้เป็นพื้นฐาน:

```bash
docker run -d \
  --name cubeos \
  --privileged \
  --net=host \
  -v ~/cubeos-data:/data \
  --device /dev/ttyUSB0:/dev/ttyUSB0 \
  -v /run/dbus/system_bus_socket:/host_dbus/system_bus_socket:ro \
  ghcr.io/ewelinkcube/cube-os:latest
```

<div align="left"><figure><img src="/files/83886d2d9efb692a35801aa61c25bedab0154ee0" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
หากคุณไม่ได้ใช้ Zigbee ให้เอาออก `--device /dev/ttyUSB0:/dev/ttyUSB0`.

หากคุณไม่ได้ใช้ Matter Hub หรือ eWeLink Remote คุณสามารถเอาการเมานต์ D-Bus ออกได้เช่นกัน
{% endhint %}
{% endstep %}

{% step %}
**ทำความเข้าใจพารามิเตอร์หลัก**

* `--privileged` — จำเป็นสำหรับการเข้าถึงฮาร์ดแวร์
* `--net=host` — จำเป็นสำหรับการค้นหาอุปกรณ์ใน LAN และ MQTT
* `-v ~/cubeos-data:/data` — เก็บข้อมูลของคุณไว้หลังคอนเทนเนอร์รีสตาร์ต
* `--device /dev/ttyUSB0:/dev/ttyUSB0` — ส่งผ่านดองเกิล Zigbee
* `-v /run/dbus/system_bus_socket:/host_dbus/system_bus_socket:ro` — เปิดใช้งานการเข้าถึง D-Bus สำหรับฟีเจอร์ที่รองรับ
  {% endstep %}
  {% endstepper %}

### 4. เข้าถึง CUBE OS

{% stepper %}
{% step %}
**ยืนยันว่าคอนเทนเนอร์กำลังทำงานอยู่**

```bash
docker ps
```

สถานะคอนเทนเนอร์ควรแสดง `Up`.
{% endstep %}

{% step %}
**เปิดเว็บ UI**

เปิดเบราว์เซอร์บนเครือข่ายเดียวกันแล้วไปที่ที่อยู่ใดที่อยู่หนึ่งต่อไปนี้:

* `http://<HOST_IP>/`
* <http://cube.local>

แทนที่ `<HOST_IP>` ด้วยที่อยู่ IP ของโฮสต์ Linux
{% endstep %}

{% step %}
**ใช้ที่อยู่ภายในเครื่องแบบสั้นในภายหลัง**

หลังตั้งค่าเสร็จ คุณสามารถดูรหัสย่อได้ที่หน้าการตั้งค่า

จากนั้นคุณสามารถใช้ `cube-{short-id}.local` เพื่อระบุอินสแตนซ์ CUBE OS นี้บน LAN ของคุณ
{% endstep %}
{% endstepper %}

### 5. อัปเดต CUBE OS

การติดตั้งใช้งาน Docker ไม่รองรับการอัปเดต OTA จากเว็บ UI

หากต้องการอัปเดตด้วยตนเอง:

```bash
docker stop cubeos
docker rm cubeos
docker pull ghcr.io/ewelinkcube/cube-os:latest

docker run -d \
  --name cubeos \
  --privileged \
  --net=host \
  -v ~/cubeos-data:/data \
  --device /dev/ttyUSB0:/dev/ttyUSB0 \
  -v /run/dbus/system_bus_socket:/host_dbus/system_bus_socket:ro \
  ghcr.io/ewelinkcube/cube-os:latest
```

ข้อมูลของคุณยังคงอยู่ใน `~/cubeos-data`ดังนั้นอุปกรณ์ ฉาก และการตั้งค่าจะยังคงอยู่หลังการอัปเดต

### 6. ข้อจำกัด

เนื่องจากการแยกตัวของคอนเทนเนอร์ ฟีเจอร์เหล่านี้จึงไม่พร้อมใช้งานในการติดตั้งใช้งาน Docker:

* **ส่วนเสริม** — ไม่สามารถติดตั้งหรือจัดการส่วนเสริมได้
* **ลำโพงบลูทูธ** — ไม่รองรับการส่งผ่านบลูทูธ
* **อัปเดตระบบ** — ปิดใช้งานการอัปเดต OTA ในเว็บ UI
* **รีบูต / ปิดเครื่อง** — ไม่สามารถใช้การควบคุมพลังงานระดับระบบได้

### 7. หมายเหตุสำหรับ Raspberry Pi

หากคุณรัน Docker บน Raspberry Pi โปรดตรวจสอบว่าขนาดหน้าเพจคือ `4096`:

```bash
getconf PAGE_SIZE

# หากผลลัพธ์ไม่ใช่ 4096 ให้เพิ่มบรรทัดนี้แล้วรีบูต
echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt
sudo reboot
```


---

# 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://cube.ewelink.cc/english-th/getting-started/quickstart/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.
