Files
codimd/docker-compose-helper.sh
Timmy ea11288642 fix: add Docker Compose V2 support for all management scripts
Add docker-compose-helper.sh to auto-detect and use:
- docker-compose (V1 - standalone)
- docker compose (V2 - plugin)

Update all 9 management scripts to use the helper:
- start.sh, stop.sh, restart.sh
- logs.sh, status.sh
- backup.sh, restore.sh, update.sh, cleanup.sh

This fixes "docker-compose: command not found" error on systems
with Docker Compose V2 installed.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-03-17 17:47:49 +08:00

26 lines
716 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Docker Compose 輔助函數
# 自動檢測使用 docker-compose 或 docker compose
# 檢測並設定 docker compose 命令
DOCKER_COMPOSE_CMD=""
if command -v docker-compose &> /dev/null; then
# Docker Compose V1 (獨立命令)
DOCKER_COMPOSE_CMD="docker-compose"
elif docker compose version &> /dev/null 2>&1; then
# Docker Compose V2 (docker plugin)
DOCKER_COMPOSE_CMD="docker compose"
else
echo "❌ 找不到 Docker Compose"
echo "請安裝 Docker Compose"
echo " V1: https://docs.docker.com/compose/install/"
echo " V2: 已包含在 Docker Desktop 中"
exit 1
fi
# 執行 docker compose 命令的函數
docker_compose() {
$DOCKER_COMPOSE_CMD "$@"
}