完善逻辑
This commit is contained in:
parent
ca1bdbcd2a
commit
de20bbd4ab
@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
restart_docker(){
|
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 "正在重启容器..."
|
echo "正在重启容器..."
|
||||||
docker-compose -f ./docker-compose.yml down
|
docker-compose -f ./docker-compose.yml down
|
||||||
docker-compose -f ./docker-compose.yml up -d
|
docker-compose -f ./docker-compose.yml up -d
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user