This commit is contained in:
Olia Lisa 2026-01-10 19:14:10 +08:00
parent de20bbd4ab
commit 8f70ddc2ce

View File

@ -2,8 +2,8 @@
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