docker-redis/service
2024-02-22 14:57:55 +08:00

23 lines
495 B
Bash
Executable File

#!/bin/bash
# 获取脚本所在目录的绝对路径
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
# 切换工作目录到脚本所在目录
cd $SCRIPT_DIR
container_name="redis"
if [ "$1" = "start" ]; then
docker compose up -d
elif [ "$1" = "stop" ]; then
docker compose down
elif [ "$1" = "restart" ]; then
docker compose down
docker compose up -d
elif [ "$1" = "status" ]; then
docker ps -a | grep $container_name
else
echo "Usage: $0 [start|stop|restart|status]"
fi