通过Docker快速搭建个人wiki,开源wiki系统用于知识沉淀,教学管理,技术学习
部署步骤
## 拉取 MrDoc 代码
### 开源版:
git clone https://gitee.com/zmister/MrDoc.git
### 专业版:
git clone https://{用户名}:{密码}@git.mrdoc.pro/MrDoc/MrDocPro.git
git clone https://mrdoc:123456@git.mrdoc.pro/MrDoc/MrDocPro.git
# ### 拉取镜像
docker pull zmister/mrdoc:v5
# ### 导入离线镜像 离线 Docker 镜像下载链接: [https://pan.baidu.com/s/1OExl7iEz62YSF4u6aQ0UGA?pwd=fr87](https://pan.baidu.com/s/1OExl7iEz62YSF4u6aQ0UGA?pwd=fr87) 提取码: fr87
docker load -i docker-mrdoc-env.v5.tar
# 准备目录
(base) [lh@tiger001 dockers]$ mkdir MrDoc
/home/lh/dockers/MrDoc/MrDoc
(base) [lh@tiger001 MrDoc]$ pwd
/home/lh/dockers/MrDoc
# ## 运行 Docker 容器
### 开源版:
docker run -d --name mrdoc -p 10086:10086 -v /home/lh/dockers/MrDoc/MrDoc:/app/MrDoc zmister/mrdoc:v5
### 专业版:
docker run -d --name mrdocpro -p 10087:10087 -v /home/lh/dockers/MrDoc/myDocPro/MrDocPro:/app/MrDoc zmister/mrdoc:v5
# 数据库准备
(base) [lh@tiger001 ~]$ docker exec -it mymysql57 bash
bash-4.2# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.41-log MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show grants for root
-> ;
+-------------------------------------------------------------+
| Grants for root@% |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.02 sec)
mysql> create user 'mrdoc'@'%' IDENTIFIED BY 'nongfuspring';
Query OK, 0 rows affected (0.44 sec)
mysql> grant ALL on *.* to 'mrdoc'@'%';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
mysql> show grants for mrdoc;
+--------------------------------------------+
| Grants for mrdoc@% |
+--------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'mrdoc'@'%' |
+--------------------------------------------+
1 row in set (0.00 sec)
mysql>
CREATE DATABASE myMrDoc DEFAULT CHARACTER SET = 'utf8mb4';
# 管理
### 配置mysql数据库依赖
### 安装 mysqlclient
docker exec -it mrdoc pip install mysqlclient
### 初始化数据库
python manage.py makemigrations
python manage.py migrate
### 创建管理员账户
docker exec -it mrdoc python manage.py createsuperuser
### 修改用户密码
docker exec -it mrdoc python manage.py changepassword admin
# lhcomeon
### 停止容器
docker stop mrdoc
### 删除容器
docker rm -f mrdoc
### 启动容器
docker start mrdoc
### 查看日志
docker logs mrdoc
关闭防火墙
“Table ‘mymrdoc.auth_user’ doesn’t exist”
需要初始化数据库
/app/MrDoc # python manage.py makemigrations
No changes detected
/app/MrDoc # python manage.py migrate
Operations to perform:
Apply all migrations: admin, app_admin, app_api, app_doc, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying app_admin.0001_initial... OK
Applying app_admin.0002_auto_20191117_0808... OK
Applying app_admin.0003_auto_20191117_0816... OK
Applying app_admin.0004_auto_20191121_2103... OK
Applying app_admin.0005_auto_20191125_2155... OK
Applying app_admin.0006_registercode... OK
Applying app_admin.0007_auto_20200222_1106... OK
Applying app_admin.0008_useroptions... OK
Applying app_api.0001_initial... OK
Applying app_api.0002_auto_20200322_0929... OK
Applying app_api.0003_appusertoken... OK
Applying app_doc.0001_initial... OK
Applying app_doc.0002_doc_pre_content... OK
Applying app_doc.0003_auto_20190717_0915... OK
Applying app_doc.0004_auto_20190717_0939... OK
Applying app_doc.0005_auto_20190727_1232... OK
Applying app_doc.0006_auto_20191215_1910... OK
Applying app_doc.0007_auto_20191221_1035... OK
Applying app_doc.0008_auto_20191221_1055... OK
Applying app_doc.0009_projectreport... OK
Applying app_doc.0010_auto_20200310_2032... OK
Applying app_doc.0011_auto_20200313_2143... OK
Applying app_doc.0012_auto_20200313_2204... OK
Applying app_doc.0013_image_file_name... OK
Applying app_doc.0014_auto_20200322_1459... OK
Applying app_doc.0015_projectcollaborator... OK
Applying app_doc.0016_attachment... OK
Applying app_doc.0017_auto_20200404_0934... OK
Applying app_doc.0018_dochistory... OK
Applying app_doc.0019_dochistory_create_user... OK
Applying app_doc.0020_projectreportfile... OK
Applying app_doc.0021_projectreport_allow_pdf... OK
Applying app_doc.0022_auto_20200618_2024... OK
Applying app_doc.0023_auto_20200620_2009... OK
Applying app_doc.0024_doctag_tag... OK
Applying app_doc.0025_doc_editor_mode... OK
Applying app_doc.0026_auto_20200905_2225... OK
Applying app_doc.0027_projecttoc... OK
Applying app_doc.0028_docshare... OK
Applying app_doc.0029_auto_20201101_2050... OK
Applying app_doc.0030_auto_20201102_2115... OK
Applying app_doc.0031_remove_docshare_effective_time... OK
Applying app_doc.0032_docshare_is_enable... OK
Applying app_doc.0033_doc_open_children... OK
Applying app_doc.0034_doc_show_children... OK
Applying app_doc.0035_auto_20201221_2042... OK
Applying app_doc.0036_auto_20201229_2004... OK
Applying app_doc.0037_mycollect... OK
Applying app_doc.0038_project_is_top... OK
Applying app_doc.0039_auto_20211013_1021... OK
Applying app_doc.0040_auto_20220311_1600... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK
/app/MrDoc #
用户名必须大于5个,改为lh123
测试效果如下:
防火墙设置
# 打开防火墙端口
sudo firewall-cmd --zone=public --add-port=5000/tcp --add-port=10086/tcp --permanent
# 关闭防火墙端口
sudo firewall-cmd --zone=public --remove-port=10086/tcp --permanent
# 重载配置
sudo firewall-cmd --reload
# 查看端口是否打开
sudo firewall-cmd --zone=public --query-port=5000/tcp
注意一个大问题,docker重启后数据丢失,概率问题
部署教程参照
官方 Docker 镜像部署 - MrDoc安装手册 - MrDoc觅思文档 - 文档站
配置文件说明 - MrDoc安装手册 - MrDoc觅思文档 - 文档站