From de20bbd4abc8950b4d281f3af5e707de241cda44 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sat, 10 Jan 2026 19:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index ca42fc1..0201a11 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,13 @@ #!/bin/bash restart_docker(){ + # 如果docker容器没有启动, 则退出 + local container_status=$(docker-compose -f ./docker-compose.yml ps -q | xargs docker inspect -f '{{.State.Running}}') + if [ -z "$container_status" ] || [ "$container_status" != "true" ]; then + echo "容器未启动, 无需重启" + return + fi + echo "正在重启容器..." docker-compose -f ./docker-compose.yml down docker-compose -f ./docker-compose.yml up -d