Docker搭建Cloudreve
Cloudreve介绍:
Cloudreve 是一个基于 ThinkPHP 框架构建的开源网盘系统,旨在帮助用户以较低的成本快速搭建起既能满足个人也能满足企业需求的网盘服务。Cloudreve 支持多种存储介质,包括但不限于本地存储、阿里云OSS、腾讯云COS、七牛云Kodo、AWS S3等,这使得用户可以根据自己的实际需求选择合适的存储方案。
主要特点
多用户支持:Cloudreve 支持多用户注册与登录,每个用户都有独立的空间和权限设置。
丰富的文件操作:提供上传、下载、分享、在线预览等功能,支持对文件和文件夹的各种操作。
安全可靠:采用加密传输,保护数据的安全;同时支持多种身份验证方式,如LDAP、OAuth2等,增强系统的安全性。
灵活的扩展性:支持插件扩展,可以通过开发或安装第三方插件来增加更多功能。
多语言支持:界面支持多国语言,方便不同地区的用户使用。
易于部署:提供详细的安装指南,支持多种环境下的部署,包括直接安装和通过Docker部署。
手动搭建过程:
搭建Docker环境
[root@k8s-master ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo [root@k8s-master ~]# yum -y install docker-ce [root@k8s-master ~]# systemctl enable docker && systemctl start docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@master ~]# vi /etc/docker/daemon.json { "registry-mirrors": [ "https://rtgofewn.mirror.aliyuncs.com", "https://docker.m.daocloud.io"], "exec-opts": ["native.cgroupdriver=systemd"] } [root@k8s-master ~]# systemctl daemon-reload [root@k8s-master ~]# systemctl restart docker [root@k8s-master ~]# systemctl status docker |
拉取Cloudreve镜像:
[root@localhost ~]# docker pull cloudreve/cloudreve Using default tag: latest latest: Pulling from cloudreve/cloudreve 96526aa774ef: Pull complete 75ac63dd6019: Pull complete 374e97e9cf49: Pull complete 23d2674c94ed: Pull complete Digest: sha256:b6c8bfd463898354831c311fb3967a410714a5319b5a86c4bf5d89e0487cc5bd Status: Downloaded newer image for cloudreve/cloudreve:latest docker.io/cloudreve/cloudreve:latest [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE cloudreve/cloudreve latest 328970d33c60 13 months ago 108MB |
创建挂载目录,创建容器:
[root@localhost ~]# mkdir -p /data/cloudreve/uploads [root@localhost ~]# docker run -d --name cloudreve \ > -p 4777:5212 --restart=always \ > -v /data/cloudreve/uploads:/cloudreve/uploads \ > cloudreve/cloudreve:latest 7f715831ed776e47e4f6085276661c4ae99ca4bc5a3a19a301cfdec0ae17d8d4 |
查看容器运行状态:
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7f715831ed77 cloudreve/cloudreve:latest "./cloudreve" 3 seconds ago Up 2 seconds 5212/tcp, 0.0.0.0:4777->5212/tcp, :::4777->5212/tcp cloudreve |
查看初始化登陆的账户和密码:
[root@localhost ~]# docker logs cloudreve ___ _ _ / __\ | ___ _ _ __| |_ __ _____ _____ / / | |/ _ \| | | |/ _ | '__/ _ \ \ / / _ \ / /___| | (_) | |_| | (_| | | | __/\ V / __/ \____/|_|\___/ \__,_|\__,_|_| \___| \_/ \___| V3.8.3 Commit #88409cc Pro=false ================================================ [Info] 2024-11-15 09:17:38 Initializing database connection... [Info] 2024-11-15 09:17:38 Start initializing database schema... [Info] 2024-11-15 09:17:38 Admin user name: admin@cloudreve.org [Info] 2024-11-15 09:17:38 Admin password: gKDvvM6B [Info] 2024-11-15 09:17:38 Start executing database script "UpgradeTo3.4.0". [Info] 2024-11-15 09:17:38 Finish initializing database schema. [Info] 2024-11-15 09:17:38 Initialize task queue with WorkerNum = 10 [Info] 2024-11-15 09:17:38 Initialize crontab jobs... [Info] 2024-11-15 09:17:38 Current running mode: Master. [Info] 2024-11-15 09:17:38 Listening to ":5212" [Info] 2024-11-15 09:18:38 Signal terminated received, shutting down server... [Error] 2024-11-15 09:18:38 Failed to listen to ":5212": http: Server closed [Warning] 2024-11-15 09:18:38 Failed to persist cache: open temp/cache_persist.bin: no such file or directory |
进入浏览器进行初始化:
使用日志中给到的初始登陆账号密码进行登录:
在主页管理面板中可以进行设置账户名和密码:
搭建完成。
Shell脚本安装直通车:
#!/bin/bash #基于阿里云的yum源,搭建Docker环境 logfile=/var/log/docker_install.log touch $logfile #基础环境,为后续访问成功做准备 systemctl stop firewalld && systemctl disable firewalld setenforce 0 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum -y install wget #下载Docker的yum源 wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo if [ $? -ne 0 ];then echo "docker的yum源获取失败,失败信息$(wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo 2>&1)" >> $logfile exit 1 else echo "docker的yum源获成功,即将安装Docker" >> $logfile fi yum install -y docker-ce if [ $? -ne 0 ];then echo "docker-ce安装失败,失败信息$(yum -y install docker-ce 2>&1)" >> $logfile exit 1 else echo "docker-ce安装完成,即将启动Docker" >> $logfile fi systemctl start docker && systemctl enable docker daemonfile=/etc/docker/daemon.json touch $daemonfile json_content='{ "registry-mirrors": [ "https://rtgofewn.mirror.aliyuncs.com", "https://docker.m.daocloud.io"], "exec-opts": ["native.cgroupdriver=systemd"] }' file_path="$daemonfile" echo "$json_content" > "$file_path" systemctl daemon-reload systemctl restart docker if [ $? -ne 0 ];then echo "添加镜像加速器后docker启动失败,失败信息(systemctl restart docker 2>&1)" >> $logfile exit 1 else echo "镜像加速器配置完成" >> $logfile fi docker pull cloudreve/cloudreve if [ $? -ne 0 ];then echo "cloudreve镜像拉取失败,请检查是否是网络问题或镜像加速问题。" >> $logfile exit 1 else echo "cloudreve镜像拉取成功" >> $logfile fi dir=/data/cloudreve/uploads mkdir -p $dir docker run -d --name cloudreve -p 4777:5212 --restart=always -v /data/cloudreve/uploads:/cloudreve/uploads cloudreve/cloudreve:latest if [ $? -ne 0 ];then echo "cloudreve容器创建失败,请检查Docker状态是否正常" >> $logfile exit 1 else echo "cloudreve容器创建成功" >> $logfile fi echo "cloudreve服务创建成功,请到浏览器进行登陆:ip:4777" echo "使用docker logs cloudreve命令获取初始Admin账户和密码" |
网站访问即可