15 lines
464 B
Bash
15 lines
464 B
Bash
#!/bin/bash
|
|
|
|
run(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
local docker_compose_file="$script_dir/../docker-compose.yml"
|
|
local running_count=$(docker-compose -f "$docker_compose_file" ps -q --filter "status=running" | wc -l)
|
|
|
|
# 如果容器已启动
|
|
if [ "$running_count" -gt 0 ]; then
|
|
docker-compose -f "$docker_compose_file" down # 关闭容器
|
|
fi
|
|
|
|
docker-compose -f "$docker_compose_file" up -d # 启动容器
|
|
}
|