跳转至

04.docker的alist配置使用

alist安装

建立一个保存alist的文件路径

mkdir /home/data/alist/etc/alist

然后我们在/home/data/alist文件夹下建立docker-compose.yml文件,由于我使用的是自建的网络,所以在生成容器前要建一个网络

version: '3.3'
services:
    alist:
        container_name: alist
        restart: always
        volumes:
            - ./etc/alist:/opt/alist/data
        ports:
            - 5244:5244
        environment:
            - PUID=1000
            - PGID=1000
            - UMASK=022
        image: xhofe/alist:latest
        networks:
            - my_net
networks:
    my_net:
        name: lqh_net

然后在这个文件夹下执行命令,生成容器

docker-compose up -d

生成完成后,就可以在服务器上输入IP:5244,然后就可以看到生成的alist服务了

alist简单使用

查询容器的启动日志,得到 admin 用户的密码

docker logs alist

里面有一条信息,Successfully created the admin user and the initial password is:xxxxxx,然后就可以在网页上登陆了。

登陆后,先点击下面的管理,在个人资料中,更改用户密码,更改完成后,要重新登陆

然后就可以在存储中添加网盘了,具体的添加放方法看官网Alist官网

小雅超集

上面的是我们自己常用的,但是小雅超集是一个别人用alist搭建的一个资料集,有很多的视频资料,他也是Docker镜像,我们可以直接使用。

官网链接

一键安装

bash -c "$(curl http://docker.xiaoya.pro/update_new.sh)"

如果你的服务器无法直接访问这个链接,也可以建立一个update_new.sh文件,然后执行

if [ -d /etc/xiaoya/mytoken.txt ]; then
    rm -rf /etc/xiaoya/mytoken.txt
fi
mkdir -p /etc/xiaoya
touch /etc/xiaoya/mytoken.txt
touch /etc/xiaoya/myopentoken.txt
touch /etc/xiaoya/temp_transfer_folder_id.txt

mytokenfilesize=$(cat /etc/xiaoya/mytoken.txt)
mytokenstringsize=${#mytokenfilesize}
if [ $mytokenstringsize -le 31 ]; then
    echo -e "\033[32m"
    read -p "输入你的阿里云盘 Token(32位长): " token
    token_len=${#token}
    if [ $token_len -ne 32 ]; then
        echo "长度不对,阿里云盘 Token是32位长"
        echo -e "安装停止,请参考指南配置文件\nhttps://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f \n"
        echo -e "\033[0m"
        exit
    else    
        echo $token > /etc/xiaoya/mytoken.txt
    fi
    echo -e "\033[0m"
fi  

myopentokenfilesize=$(cat /etc/xiaoya/myopentoken.txt)
myopentokenstringsize=${#myopentokenfilesize}
if [ $myopentokenstringsize -le 279 ]; then
    echo -e "\033[33m"
        read -p "输入你的阿里云盘 Open Token(280位长或者335位长): " opentoken
    opentoken_len=${#opentoken}
        if [[ $opentoken_len -ne 280 ]] && [[ $opentoken_len -ne 335 ]]; then
                echo "长度不对,阿里云盘 Open Token是280位长或者335位"
        echo -e "安装停止,请参考指南配置文件\nhttps://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f \n"
        echo -e "\033[0m"
                exit
        else
            echo $opentoken > /etc/xiaoya/myopentoken.txt
    fi
    echo -e "\033[0m"
fi

folderidfilesize=$(cat /etc/xiaoya/temp_transfer_folder_id.txt)
folderidstringsize=${#folderidfilesize}
if [ $folderidstringsize -le 39 ]; then
    echo -e "\033[36m"
        read -p "输入你的阿里云盘转存目录folder id: " folderid
    folder_id_len=${#folderid}
    if [ $folder_id_len -ne 40 ]; then
                echo "长度不对,阿里云盘 folder id是40位长"
        echo -e "安装停止,请参考指南配置文件\nhttps://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f \n"
        echo -e "\033[0m"
                exit
        else
            echo $folderid > /etc/xiaoya/temp_transfer_folder_id.txt
    fi  
    echo -e "\033[0m"
fi

echo "new" > /etc/xiaoya/show_my_ali.txt
localip=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|grep -v 172|head -n1)
if [ $1 ]; then
if [ $1 == 'host' ]; then
    if [ ! -s /etc/xiaoya/docker_address.txt ]; then
        echo "http://$localip:6789" > /etc/xiaoya/docker_address.txt
    fi  
    docker stop xiaoya-hostmode
    docker rm xiaoya-hostmode
    docker rmi xiaoyaliu/alist:hostmode
    docker pull xiaoyaliu/alist:hostmode
    if [[ -f /etc/xiaoya/proxy.txt ]] && [[ -s /etc/xiaoya/proxy.txt ]]; then
            proxy_url=$(head -n1 /etc/xiaoya/proxy.txt)
        docker run -d --env HTTP_PROXY="$proxy_url" --env HTTPS_PROXY="$proxy_url" --env no_proxy="*.aliyundrive.com" --network=host -v /etc/xiaoya:/data --restart=always --name=xiaoya-hostmode xiaoyaliu/alist:hostmode
    else    
        docker run -d --network=host -v /etc/xiaoya:/data --restart=always --name=xiaoya-hostmode xiaoyaliu/alist:hostmode
    fi  
    exit
fi
fi

if [ ! -s /etc/xiaoya/docker_address.txt ]; then
        echo "http://$localip:5678" > /etc/xiaoya/docker_address.txt
fi
docker stop xiaoya
docker rm xiaoya
docker rmi xiaoyaliu/alist:latest 
docker pull xiaoyaliu/alist:latest
if [[ -f /etc/xiaoya/proxy.txt ]] && [[ -s /etc/xiaoya/proxy.txt ]]; then
    proxy_url=$(head -n1 /etc/xiaoya/proxy.txt)
        docker run -d -p 5678:80 -p 2345:2345 --env HTTP_PROXY="$proxy_url" --env HTTPS_PROXY="$proxy_url" --env no_proxy="*.aliyundrive.com" -v /etc/xiaoya:/data --restart=always --name=xiaoya xiaoyaliu/alist:latest
else
    docker run -d -p 5678:80 -p 2345:2345 -v /etc/xiaoya:/data --restart=always --name=xiaoya xiaoyaliu/alist:latest
fi  

你需要提前准备好3个东西

对应文件 获取方式
token /etc/xiaoya/mytoken.txt https://aliyuntoken.vercel.app/ https://alist.nn.ci/zh/guide/drivers/aliyundrive.html
open token /etc/xiaoya/myopentoken.txt https://alist.nn.ci/zh/guide/drivers/aliyundrive_open.html
转存目录的folder id /etc/xiaoya/temp_transfer_folder_id.txt 先转存这个https://www.aliyundrive.com/s/rP9gP3h9asE 到自己网盘(选择资源盘),然后浏览器打开转存后的目录,浏览器的url https://www.aliyundrive.com/drive/file/resource/640xxxxxxxxxxxxxxxxxxxca8a 最后一串就是,记得这个目录不要删,里面的内容可以定期删除

这三个文件,要提前准备好里面要填的内容,就在获取方式,然后,运行上面的安装文件,就会让你填入这些信息。

等待安装完成后,访问IP:5678就可以了。

由于他的原理是将文件转存到你的百度网盘进行查看,所以要是内容过多,我们要定时删除网盘中的这些文件,下面的命令就是添加一个docker应用,专门来清理网盘缓存,后面的tg可以不用加,常用的模式是模式3和5

#模式0:每天自动清理一次。如果系统重启需要手动重新运行或把命令加入系统启动。
bash -c "$(curl -s https://xiaoyahelper.zengge99.eu.org/aliyun_clear.sh | tail -n +2)" -s 0 -tg

#模式1:一次性清理,一般用于测试效果。
bash -c "$(curl -s https://xiaoyahelper.zengge99.eu.org/aliyun_clear.sh | tail -n +2)" -s 1 -tg

#模式2:已废弃

#模式3:创建一个名为 xiaoyakeeper 的docker定时运行小雅转存清理并升级小雅镜像
bash -c "$(curl -s https://xiaoyahelper.zengge99.eu.org/aliyun_clear.sh | tail -n +2)" -s 3 -tg

#模式4:同模式3

#模式5:与模式3的区别是实时清理,只要产生了播放缓存一分钟内立即清理。签到和定时升级同模式3
bash -c "$(curl -s https://xiaoyahelper.zengge99.eu.org/aliyun_clear.sh | tail -n +2)" -s 5 -tg