docs(deploy): แก้ปัญหา container name conflict ตอน deploy บน Dokploy

This commit is contained in:
Bkk1234 committed 2026-11-24 15:32:28 +07:00
1 parent a8a022ec54
commit fc8bc4d1d7
1 file changed
+34
+34
View File
@@ -124,3 +124,37 @@ PORT=31004 HOST_PORT=31004 PUBLIC_ORIGIN=https://staging.example.com docker comp
- canonical/OG/sitemap/robots: ตั้ง `PUBLIC_ORIGIN` (runtime) หรือแทนสตริงในไฟล์ตอน publish - canonical/OG/sitemap/robots: ตั้ง `PUBLIC_ORIGIN` (runtime) หรือแทนสตริงในไฟล์ตอน publish
- อย่าแก้ attribute ใน HTML ด้วยมือหลังจากที่ไฟล์ถูก hydrate แล้ว — จะ hydration mismatch - อย่าแก้ attribute ใน HTML ด้วยมือหลังจากที่ไฟล์ถูก hydrate แล้ว — จะ hydration mismatch
- หน้า `/cinema/<slug>` ไม่มี trailing slash (canonical เป็นแบบนั้น) — nginx `try_files $uri $uri/index.html` เสิร์ฟตรง ไม่ redirect - หน้า `/cinema/<slug>` ไม่มี trailing slash (canonical เป็นแบบนั้น) — nginx `try_files $uri $uri/index.html` เสิร์ฟตรง ไม่ redirect
## แก้ปัญหา: container name conflict ตอน deploy
อาการ
```
Error response from daemon: Conflict. The container name
"/alterflixhub-compose-doefaz-web-1" is already in use by container "e52fbe…"
```
สาเหตุ: มี container จาก deploy รอบก่อนค้างอยู่ (สถานะ `Created`/`Exited` หรือค้างจาก compose project ชื่อเดิม)
แล้ว Docker ไม่ยอมสร้างตัวใหม่ทับชื่อเดิม — **ไม่ใช่บั๊กของแอป** และไม่เกี่ยวกับ image/build
แก้ (เลือกทางใดทางหนึ่ง บนเครื่องที่รัน Docker / Terminal ของ Dokploy)
```bash
# 1) ลบ container ที่ค้างชื่อไว้ (ปลอดภัย: เป็น static site ไม่มีข้อมูลใน container)
docker rm -f e52fbeb2b29e # ใช้ id จากข้อความ error
# 2) หรือล้างทั้ง stack ของ project นี้แล้วขึ้นใหม่
docker compose -p alterflixhub-compose-doefaz down --remove-orphans
docker compose -p alterflixhub-compose-doefaz up -d --build --remove-orphans
```
ตรวจว่าหมดจริงก่อน deploy ซ้ำ
```bash
docker ps -a --filter "name=alterflixhub" --format '{{.ID}}\t{{.Names}}\t{{.Status}}'
```
หมายเหตุ
- compose นี้ **ไม่ตั้ง `container_name`** โดยเจตนา (กันชนกันหลาย stack) — ชื่อที่เห็นเป็นชื่อที่ compose สร้างจากชื่อ project
- ถ้ายังซ้ำอีก ให้ deploy ด้วย `--remove-orphans` เสมอ หรือลบ container เก่าก่อน redeploy
- หลัง deploy สำเร็จ ตรวจว่าไฟล์ใหม่ขึ้นจริง: `curl -s https://<โดเมน>/sw.js | grep "const VERSION"` ต้องได้ `v2.1.4`