【云原生之Docker实战】使用Docker部署ShowDoc文档工具

@TOC

一、ShowDoc介绍

1.ShowDoc简介

ShowDoc是一个非常适合IT团队的在线API文档、技术文档工具。通过showdoc,你可以方便地使用markdown语法来书写出美观的API文档、数据字典文档、技术文档、在线excel文档等等。

2.ShowDoc功能

  • 分享与导出响应式网页设计,可将项目文档分享到电脑或移动设备查看。同时也可以将项目导出成word文件,以便离线浏览。
  • 权限管理1.公开项目与私密项目:ShowDoc上的项目有公开项目和私密项目两种。公开项目可供任何登录与非登录的用户访问,而私密项目则需要输入密码验证访问。密码由项目创建者设置。 2.项目转让:项目创建者可以自由地把项目转让给网站的其他用户。 3.项目成员:你可以很方便地为ShowDoc的项目添加、删除项目成员。项目成员可以对项目进行编辑,但不可转让或删除项目(只有项目创建者才有权限)。 4.团队管理:利用showdoc的团队功能你可以更好地进行团队协作。
  • 编辑功能1.markdown编辑:ShowDoc采用markdown编辑器,无论是编辑还是阅读体验都极佳很棒。 2.模板插入:在ShowDoc的编辑页面,点击编辑器上方的按钮可方便地插入API接口模板和数据字典模板。 3.历史版本:ShowDoc为页面提供历史版本功能,你可以方便地把页面恢复到之前的版本。
  • 多平台showdoc支持网页版、手机app版和电脑客户端版。客户端地址可见:https://www.showdoc.com.cn/clients。
  • 自动化1.可从代码注释中自动生成文档。 2.搭配的RunApi客户端,可调试接口和自动生成文档。

二、检查docker版本

代码语言:shell
复制
[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状态

代码语言:shell
复制
[root@docker showdoc]# ls
[root@docker showdoc]# 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 Sun 2022-10-23 19:15:37 CST; 3h 21min ago
Docs: https://docs.docker.com
Main PID: 9693 (dockerd)
Tasks: 51
Memory: 1.5G
CGroup: /system.slice/docker.service

四、下载ShowDoc镜像

代码语言:shell
复制
[root@docker showdoc]# docker pull star7th/showdoc
Using default tag: latest
latest: Pulling from star7th/showdoc
59bf1c3509f3: Pull complete
7c7da25b2876: Pull complete
2bc599114627: Pull complete
927a0b37a45a: Pull complete
1766f36e2432: Pull complete
4c13e0891ac6: Pull complete
2cec0bbb4ba9: Pull complete
b36e8fdf0264: Pull complete
387739aab6be: Pull complete
d73f4116d27c: Pull complete
ac2614199456: Pull complete
8cf23d77585a: Pull complete
2595abc0c000: Pull complete
e19d5b33c59c: Pull complete
3c91138e3b38: Pull complete
e1e2f7050886: Pull complete
ddf7a600aa8d: Pull complete
c21a6cac05ae: Pull complete
4ee11851e20a: Pull complete
5a9839199e80: Pull complete
b6f89a4d0e50: Pull complete
f7a113ae7a21: Pull complete
afe348e7bc07: Pull complete
7d4f658c188c: Pull complete
1949b55bfafc: Pull complete
18fc12f9ed58: Pull complete
debcc98cda0a: Pull complete
313c4ac392fa: Pull complete
654d7595e577: Pull complete
e35254510d69: Pull complete
4e973aacee4d: Pull complete
Digest: sha256:5ab4cec5e2e0c75d02e62c924a0457fc2751c1ce8f056f30f2920f88d431de39
Status: Downloaded newer image for star7th/showdoc:latest
docker.io/star7th/showdoc:latest

五、创建ShowDoc容器

1.创建数据目录

代码语言:shell
复制
mkdir -p /data/showdoc/html

2目录授权

代码语言:shell
复制
[root@docker showdoc]# chmod -R 777 /data/showdoc/
[root@docker showdoc]#

3.运行ShowDoc容器

代码语言:shell
复制
[root@docker showdoc]# docker run -d --name showdoc --user=root --privileged=true -p 4999:80 
> --restart always -v /data/showdoc/html:/var/www/html/ star7th/showdoc
56c200dbb93e621d20258624a05c39e110beb8261e86fcac30a95a75d3074578

4.查看ShowDoc容器状态

代码语言:shell
复制
[root@docker showdoc]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56c200dbb93e star7th/showdoc "/entrypoint /bin/sh…" 23 seconds ago Up 22 seconds 443/tcp, 9000/tcp, 0.0.0.0:4999->80/tcp, :::4999->80/tcp showdoc

5.查看容器运行日志

代码语言:shell
复制
[root@docker showdoc]# docker logs showdoc
/usr/lib/python3.9/site-packages/supervisor/options.py:474: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
self.warnings.warn(
2022-10-23 14:50:21,648 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/cron.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/dnsmasq.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/nginx.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/php-fpm.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/postfix.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/ssh.conf" during parsing
2022-10-23 14:50:21,649 INFO Included extra file "/opt/docker/etc/supervisor.d/syslog.conf" during parsing
2022-10-23 14:50:21,653 INFO RPC interface 'supervisor' initialized
2022-10-23 14:50:21,653 INFO supervisord started with pid 1
2022-10-23 14:50:22,655 INFO spawned: 'syslogd' with pid 49
2022-10-23 14:50:22,657 INFO spawned: 'nginxd' with pid 50
2022-10-23 14:50:22,658 INFO spawned: 'php-fpmd' with pid 51
2022-10-23 14:50:22,660 INFO spawned: 'crond' with pid 52
-> Executing /opt/docker/bin/service.d/syslog-ng.d//10-init.sh
2022-10-23 14:50:22,663 INFO success: nginxd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2022-10-23 14:50:22,663 INFO success: php-fpmd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2022-10-23 14:50:22,663 INFO success: crond entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
-> Executing /opt/docker/bin/service.d/nginx.d//10-init.sh
-> Executing /opt/docker/bin/service.d/php-fpm.d//10-init.sh
Setting php-fpm user to application
[2022-10-23T14:50:22.674601] WARNING: With use-dns(no), dns-cache() will be forced to 'no' too!;
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /opt/docker/etc/nginx/vhost.ssl.conf:1
[SYSLOG] syslog-ng[49]: syslog-ng starting up; version='3.30.1'
-> Executing /opt/docker/bin/service.d/cron.d//10-init.sh
[23-Oct-2022 14:50:22] NOTICE: fpm is running, pid 51
[23-Oct-2022 14:50:22] NOTICE: ready to handle connections
2022-10-23 14:50:23,786 INFO success: syslogd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

> mockServer@1.0.0 start
> npm run pm2 start index.js

> mockServer@1.0.0 pm2
> node ./node_modules/pm2/bin/pm2 "start" "index.js"

                    -------------

/\\\\\\_/\\/\\/\\\\_
_/\/////////\_/\\\
/\\\/\///////\_
/\_
/\_/\//\_/\//\_/////\_
_/\\\\\\/
/\\///\/\/
/\_
/\/
/\/////////
/\_
///\/
/\_/\//_____
/\_
/\_////\_____/\//_____
/\_/\_/\_/\/__________
/\_/\_/\_/\\\\\\\_
_////////////////////////

                      Runtime Edition

    PM2 is a Production Process Manager for Node.js applications
                 with a built-in Load Balancer.

            Start and Daemonize any application:
            $ pm2 start app.js

            Load Balance 4 instances of api.js:
            $ pm2 start api.js -i 4

            Monitor in production:
            $ pm2 monitor

            Make pm2 auto-boot at server restart:
            $ pm2 startup

            To go further checkout:
            http://pm2.io/


                    -------------

[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /showdoc_data/mock/index.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ index │ default │ 1.0.0 │ fork │ 114 │ 0s │ 0 │ online │ 0% │ 17.2mb │ root │ disabled │
└─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
2022-10-23 14:50:53,821 INFO reaped unknown pid 47 (exit status 0)

六、ShowDoc初始化

1.选择语言

在这里插入图片描述

2.查看初始化结果

在这里插入图片描述

七、登录署ShowDoc

1.进入ShowDoc登录页

在这里插入图片描述

2.登录ShowDoc首页

在这里插入图片描述

八、ShowDoc的基本使用

1.进入后台管理界面

在这里插入图片描述

2.新建项目

在这里插入图片描述

3.新建与编辑文档

在这里插入图片描述
在这里插入图片描述

4.团队管理

在这里插入图片描述

我正在参与2023腾讯技术创作特训营第二期有奖征文,瓜分万元奖池和键盘手表