From a2acd6f6e4fe35614d626b228dc71c19a02dce0b Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 4 Apr 2026 08:33:48 +0000 Subject: [PATCH] =?UTF-8?q?feat(install):=20=E5=AE=89=E8=A3=85=E6=97=B6?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=20APP=5FID=20=E6=98=AF=E5=90=A6=E4=B8=8E?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=AE=9E=E4=BE=8B=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止复制项目目录到另一个位置安装时,因 APP_ID 相同导致容器名和网络冲突。 通过 docker inspect 对比容器挂载路径与当前工作目录判断。 Co-Authored-By: Claude Opus 4.6 (1M context) --- cmd | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd b/cmd index 0d2d95384..7213b6e18 100755 --- a/cmd +++ b/cmd @@ -502,6 +502,18 @@ DooTask 管理脚本 EOF } +# 检测APP_ID是否与其他实例冲突 +check_instance() { + local app_id=$(env_get APP_ID) + local container_name="dootask-php-${app_id}" + local mount_path=$(docker inspect "$container_name" --format '{{range .Mounts}}{{if eq .Destination "/var/www"}}{{.Source}}{{end}}{{end}}' 2>/dev/null) + if [[ -n "$mount_path" ]] && [[ "$mount_path" != "$WORK_DIR" ]]; then + error "APP_ID(${app_id})已被其他实例使用:${mount_path}" + error "请先清空 .env 中的 APP_ID 和 APP_IPPR 再重新安装" + exit 1 + fi +} + # 检测端口是否被占用 # 参数1: 端口号, 参数2: 当前端口号(可选,相同则跳过检测) check_port() { @@ -518,7 +530,8 @@ check_port() { # 安装函数 handle_install() { check_sudo - + check_instance + local relock=$(arg_get relock) local port=$(arg_get port)