Docker搭建可道云

作者 : admin 本文共4653个字,预计阅读时间需要12分钟 发布时间: 2024-06-10 共2人阅读

Docker搭建可道云(存储)

文章目录

  • Docker搭建可道云(存储)
    • 介绍
    • 资源列表
    • 基础环境
    • 一、安装Docker
    • 二、配置Docker加速器
    • 三、搭建可道云私有云盘
      • 3.1、编写Dockerfile
      • 3.2、上传资源到指定目录
      • 3.3、查看目录下所有资源
    • 四、构建镜像
    • 五、启动容器
    • 六、访问php解析页面
    • 七、访问可道云程序

介绍

  • 可道云的英文名称KodExplorer,在很久之前叫芒果云,是国人开发的基于Web技术的私有云和在线文档管理的开源解决方案
  • 可道云采用windows操作界面,具有专业的在线编辑器,支持Office的在线预览和编辑,可多人协同编辑作业,文档历史版本回溯;更有Photoshop、AI、AutoCAD等专业文档的在线预览,很适合办公用户。作为网盘使用,具有一键分享文件,支持生成外链;扫描二维码,受经济即可快速查看;可设定到期时间、提取密码、下载权限,满足更过场景需求,轻松将文件分享给客户、同事查看。还有很多插件可选择
  • 当然可倒运很大的优点是无需数据库,在服务器、VPS、虚拟空间、各种NAS、甚至部分路由器上都可以直接安装使用

资源列表

操作系统配置主机名IP所需软件
CentOS 7.92C4Glnmp-docker192.168.93.165Docker、kodexplorer4.40.zip、LNMP

基础环境

  • 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
  • 关闭内核安全机制
setenforce 0
sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
  • 修改主机名
hostnamectl set-hostname lnmp-docker

一、安装Docker

# 安装依赖环境
yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加CentOS官方镜像站
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
yum clean all && yum makecache
# 安装Docker
yum -y install docker-ce docker-ce-cli containerd.io
# 启动Docker
systemctl start docker
systemctl enable docker

二、配置Docker加速器

cd /etc/docker/
cat >> daemon.json << EOF
{  
"registry-mirrors": ["http://8xpk5wnt.mirror.aliyuncs.com"]  
}
EOF
systemctl restart docker

# 查看Docker版本
docker version

三、搭建可道云私有云盘

3.1、编写Dockerfile

# 创建工作目录
[root@lnmp-docker ~]# mkdir /root/lnmp
[root@lnmp-docker ~]# cd /root/lnmp/
[root@lnmp-docker lnmp]# cat Dockerfile 
FROM centos:7
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#安装nginx和php
RUN yum install nginx php-mbstring php-fpm php-gd php-mysql -y
#复制php配置文件
ADD www.conf /etc/php-fpm.d/www.conf
#复制nginx配置文件
ADD nginx.conf /etc/nginx/nginx.conf
RUN mkdir /html
WORKDIR /html

#复制程序文件
COPY kodexplorer4.40.zip .
RUN yum install unzip -y
RUN unzip kodexplorer4.40.zip
RUN chown -R nginx:nginx .

# 复制php界面页面
COPY test.php /html

#安装mysql
RUN yum install mariadb-server -y

#添加并运行脚本
ADD init.sh /init.sh

#开放的端口
EXPOSE 80
EXPOSE 3306
EXPOSE 443
EXPOSE 9000

#每次创建容器运行此脚本
CMD ["/bin/bash","/init.sh"]

3.2、上传资源到指定目录

##################################################################
# 创建CMD指定脚本
[root@lnmp-docker lnmp]# cat init.sh 
#!/bin/bash
#初始化mysql
/usr/libexec/mariadb-prepare-db-dir &>/dev/null &
#启动mysql
/usr/bin/mysqld_safe --basedir=/usr &>/dev/null &
#休眠5s
sleep 5
#创建数据库kod
mysql -e "create database kod;"
mysql -e "grant all on kod.* to discuz@localhost identified by '123456'";
#启动php-fpm
/usr/sbin/php-fpm --daemonize
#nginx在前台启动
nginx -g 'daemon off;'
##################################################################
##################################################################
# 创建nginx配置文件
[root@lnmp-docker lnmp]# cat nginx.conf 
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log  /var/log/nginx/access.log  main;
sendfile           on;
tcp_nopush         on;
tcp_nodelay        on;
keepalive_timeout  65;
types_hash_max_size 2048;
include            /etc/nginx/mime.types;
default_type       application/octet-stream;
server  {
listen 80;
server_name    localhost;
root           /html;
index          index.php index.html;
location ~ \.php$ {
root           /html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}
}
}
##################################################################
##################################################################
# 创建php配置文件
[root@lnmp-docker lnmp]# cat www.conf | grep -v ";" | grep -v "^$"
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache
##################################################################
##################################################################
# 创建php解析页面
[root@lnmp-docker lnmp]# cat test.php 
<?php
$link=mysql_connect("localhost","discuz","123456");
if(link)
echo "The connection is successfully!";
mysql_close();
?>
##################################################################

3.3、查看目录下所有资源

[root@lnmp-docker lnmp]# ls
Dockerfile  init.sh  kodexplorer4.40.zip  nginx.conf  test.php  www.conf

四、构建镜像

[root@lnmp-docker lnmp]# docker build -t centos:lnmp .

五、启动容器

[root@lnmp-docker lnmp]# docker run -d -p 80:80 --name lnmp centos:lnmp

六、访问php解析页面

[root@lnmp-docker lnmp]# curl 192.168.93.165/test.php
The connection is successfully!

七、访问可道云程序

  • 访问地址:http://192.168.93.165,就可以看到可道云页面了!!!
  • 设置管理用户(admin)密码,使用此密码登录就可以访问啦
    Docker搭建可道云插图
    Docker搭建可道云插图(1)
    Docker搭建可道云插图(2)
本站无任何商业行为
个人在线分享 » Docker搭建可道云
E-->