diff --git a/install.sh b/install.sh index 0201a11..fbca21b 100644 --- a/install.sh +++ b/install.sh @@ -2,11 +2,11 @@ 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 + local running_count=$(docker-compose -f ./docker-compose.yml ps -q | wc -l) + if [ "$running_count" -eq 0 ]; then echo "容器未启动, 无需重启" return - fi + fi echo "正在重启容器..." docker-compose -f ./docker-compose.yml down