source ../environment.sh
if [ -z "$NETWORK" ]; then
    echo "错误: 未找到 NETWORK 环境变量"
    exit 1
fi
if [ -z "$REDIS_PORT" ]; then
    echo "错误: 未找到 REDIS_PORT 环境变量"
    exit 1
fi

if [ -z "$REDIS_DATA" ]; then
    echo "错误: 未找到 REDIS_DATA 环境变量"
    exit 1
fi

if docker ps -a | grep -q ${REDIS_NAME}; then
    echo "停止并删除已存在的 REDIS 容器..."
    docker stop ${REDIS_NAME} >/dev/null 2>&1
    docker rm ${REDIS_NAME} >/dev/null 2>&1
fi

docker run -d \
--name ${REDIS_NAME} \
--network $NETWORK \
-p ${REDIS_PORT}:6379 \
-v ${REDIS_DATA}:/data \
--memory ${REDIS_MEMORY} \
--restart unless-stopped \
${REDIS_IMAGE}
docker ps