(云原生之使用Docker部署kkFileView在线文档管理平台)
一、kkFileView介绍
1.kkFileView简介
kkFileView是一个开源在线文档工具,使用spring boot打造文件文档在线预览项目解决方案,支持doc、docx、ppt、pptx、xls、xlsx、zip、rar、mp4、mp3以及众多类文本如txt、html、xml、java、properties、sql、js、md、json、conf、ini、vue、php、py、bat、gitignore等文件在线预览。
2.kkFileView特点
- 支持 office, pdf, cad 等办公文档。
- 支持 txt, xml(渲染), md(渲染), java, php, py, js, css 等所有纯文本。
- 支持 zip, rar, jar, tar, gzip 等压缩包。
- 支持 jpg, jpeg, png, gif, tif, tiff 等图片预览(翻转,缩放,镜像)。
- 使用 spring-boot 开发,预览服务搭建部署非常简便。
- rest 接口提供服务,跨语言、跨平台特性(java,php,python,go,php,....)都支持,应用接入简单方便。
- 抽象预览服务接口,方便二次开发,非常方便添加其他类型文件预览支持。
- 支持Apache 协议开源
二、检查本地系统环境
1.检查系统版本
[root@docker ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
2.检查docker状态
[root@node ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-10-31 03:28:51 CST; 2 days ago
Docs: https://docs.docker.com
Main PID: 11884 (dockerd)
Tasks: 69
Memory: 2.7G
CGroup: /system.slice/docker.service
├─ 2674 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8015 -container-ip 172.28.0.2 -container-port 8080
├─ 2681 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8015 -container-ip 172.28.0.2 -container-port 8080
├─ 11884 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─ 34936 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.27.0.3 -container-port 80
├─ 34950 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.27.0.3 -container-port 80
├─114721 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9000 -container-ip 172.17.0.2 -container-port 9000
├─114726 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9000 -container-ip 172.17.0.2 -container-port 9000
├─125344 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5000 -container-ip 172.17.0.3 -container-port 5000
└─125350 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5000 -container-ip 172.17.0.3 -container-port 5000
Nov 02 01:04:02 node dockerd[11884]: time="2022-11-02T01:04:02.488311529+08:00" level=warning msg="Health check for container b5103772dd...xceeded"
Nov 02 01:04:15 node dockerd[11884]: time="2022-11-02T01:04:15.531265106+08:00" level=error msg="stream copy error: reading from a closed fifo"
Nov 02 01:04:15 node dockerd[11884]: time="2022-11-02T01:04:15.534176422+08:00" level=error msg="stream copy error: reading from a closed fifo"
Nov 02 01:04:15 node dockerd[11884]: time="2022-11-02T01:04:15.545274180+08:00" level=warning msg="Health check for container b5103772dd...xceeded"
Nov 02 01:04:18 node dockerd[11884]: time="2022-11-02T01:04:18.585842485+08:00" level=info msg="ignoring event" container=b5103772dd9c15...kDelete"
Nov 02 01:04:32 node dockerd[11884]: time="2022-11-02T01:04:32.907844353+08:00" level=error msg="stream copy error: reading from a closed fifo"
Nov 02 01:04:32 node dockerd[11884]: time="2022-11-02T01:04:32.911808176+08:00" level=error msg="stream copy error: reading from a closed fifo"
Nov 02 01:04:33 node dockerd[11884]: time="2022-11-02T01:04:33.524510151+08:00" level=warning msg="Health check for container b5103772dd...unknown"
Nov 02 01:04:55 node dockerd[11884]: time="2022-11-02T01:04:55.780507781+08:00" level=info msg="ignoring event" container=5a9f357c0d2ba6...kDelete"
Nov 02 01:07:02 node dockerd[11884]: time="2022-11-02T01:07:02.501623848+08:00" level=info msg="ignoring event" container=346ef9741bfb9a...kDelete"
Hint: Some lines were ellipsized, use -l to show in full.
3.检查docker版本
[root@docker ~]# docker version
Client: Docker Engine - Community
Version: 20.10.18
API version: 1.41
Go version: go1.18.6
Git commit: b40c2f6
Built: Thu Sep 8 23:14:08 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.18
API version: 1.41 (minimum version 1.12)
Go version: go1.18.6
Git commit: e42327a
Built: Thu Sep 8 23:12:21 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
三、安装docker-compose
1.下载docker-compose二进制包
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
[root@docker docker-compose]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 423 100 423 0 0 362 0 0:00:01 0:00:01 --:--:-- 362
100 16.2M 100 16.2M 0 0 8568k 0 0:00:01 0:00:01 --:--:-- 8568k
2.给文件增加执行权限
chmod +x /usr/local/bin/docker-compose
3.检查docker-compose版本
[root@docker ~]# docker-compose version
docker-compose version 1.25.0, build 0a186604
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
四、下载kkFileView镜像
[root@node fileview]# docker pull keking/kkfileview
Using default tag: latest
latest: Pulling from keking/kkfileview
7b1a6ab2e44d: Already exists
b9d750c8748d: Pull complete
57d39c371cd2: Pull complete
816e525228e0: Pull complete
Digest: sha256:d87d106e51c78afb41c4e39d1b043d4b1bf24c7a931874e945149e2bd7e62f4f
Status: Downloaded newer image for keking/kkfileview:latest
docker.io/keking/kkfileview:latest
五、部署kkFileView
1.创建数据目录
mkdir -p /data/fileview
2.创建kkFileView容器
docker run -d --name nervous_swartz --restart always -p 8012:8012 keking/kkfileview
3.查看容器状态
[root@node fileview]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa8894458ec0 keking/kkfileview "java -Dfile.encodin…" 12 minutes ago Up 12 minutes 0.0.0.0:8012->8012/tcp, :::8012->8012/tcp nervous_swartz