一、Leanote蚂蚁笔记介绍
1.Leanote简介
Leanote 蚂蚁笔记是一款国产开源的私有云笔记工具。它支持普通格式笔记、Markdown语法、专业数学公式编辑、和思维导图,并且支持vim&emacs等编辑模式。
2.Leanote功能
拥有Markdown 语法支持、无干扰写作模式、Vim和Emacs编辑模式、将笔记导出为 PDF、可批注操作,具备可定制的博客主题,具备基础的思维导图功能,能用Docker快速本地化部署。
二、本次实践介绍
1. 本次实践简介
a.本次实践部署环境为个人笔记本ubuntu日常工作的测试环境,若是生产环境请谨慎部署;
b.本次实践为快速使用docker部署开源Leanote蚂蚁笔记于个人ubuntu上,若是需要部署在个人的服务环境也可以作为参考;正式的环境需要控制好网络策略,以及使用dockerfile去创建独立的环境,做好挂载文件的定时备份和docker日志清理,使用轻量级或者某个节点去监控对应的应用和资源。
2. 本地环境规划
本次实践环境规划:下载镜像leanote/leanote:latest,通过docker-cli或者docker compose启动容器
镜像命名 | IP地址 | 容器镜像版本 | 操作系统版本 |
---|---|---|---|
leanote | localhost | latest | ubuntu 22.04 |
三、检查本地Docker环境
1. 检查本地Docker版本
检查Docker版本:docker version
root@WellDone:/home/goodjob# docker version
Client: Docker Engine - Community
Version: 25.0.0
API version: 1.44
Go version: go1.21.6
Git commit: e758fe5
Built: Thu Jan 18 17:09:49 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.0
API version: 1.44 (minimum version 1.24)
Go version: go1.21.6
Git commit: 615dfdf
Built: Thu Jan 18 17:09:49 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.27
GitCommit: a1496014c916f9e62104b33d1bb5bd03b0858e59
runc:
Version: 1.1.11
GitCommit: v1.1.11-0-g4bccb38
docker-init:
Version: 0.19.0
GitCommit: de40ad0
root@WellDone:/home/goodjob#
2. 检查Docker服务状态
检查Docker服务状态,确保Docker服务正常运行。
systemctl status docker
root@WellDone:/home/goodjob/Downloads# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-01-24 08:54:31 CST; 1 day 4h ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1549 (dockerd)
Tasks: 65
Memory: 419.5M
CPU: 38.874s
CGroup: /system.slice/docker.service
├─ 1549 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─ 2010 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6379 -container-ip 172.17.0.2 -container-port 6379
├─ 2016 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 6379 -container-ip 172.17.0.2 -container-port 6379
├─ 2029 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5432 -container-ip 172.17.0.3 -container-port 5432
├─ 2036 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5432 -container-ip 172.17.0.3 -container-port 5432
├─123083 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.17.0.4 -container-port 8080
└─123095 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8888 -container-ip 172.17.0.4 -container-port 8080
1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.067895045+08:00" level=info msg="API listen on /run/docker.sock"
1月 24 08:54:31 WellDone systemd[1]: Started Docker Application Container Engine.
1月 24 16:13:48 WellDone dockerd[1549]: time="2024-01-24T16:13:48.185008219+08:00" level=info msg="ignoring event" container=8ad99af82d8a41dd661d>
1月 24 16:13:48 WellDone dockerd[1549]: time="2024-01-24T16:13:48.189484205+08:00" level=warning msg="ShouldRestart failed, container will not be>
1月 24 21:58:08 WellDone dockerd[1549]: time="2024-01-24T21:58:08.024915139+08:00" level=info msg="ignoring event" container=27fd28e2993f31b170b8>
1月 24 21:58:08 WellDone dockerd[1549]: time="2024-01-24T21:58:08.029986730+08:00" level=warning msg="ShouldRestart failed, container will not be>
1月 25 10:46:16 WellDone dockerd[1549]: time="2024-01-25T10:46:16.329180722+08:00" level=info msg="Container failed to exit within 10s of signal >
1月 25 10:46:16 WellDone dockerd[1549]: time="2024-01-25T10:46:16.350757439+08:00" level=info msg="ignoring event" container=b1223add00f36bbb3246>
1月 25 10:49:21 WellDone dockerd[1549]: time="2024-01-25T10:49:21.993755983+08:00" level=info msg="Container failed to exit within 10s of signal >
1月 25 10:49:22 WellDone dockerd[1549]: time="2024-01-25T10:49:22.015822650+08:00" level=info msg="ignoring event" container=edb0e153b45dbe62acd8>
lines 1-28/28 (END)
四、下载Leanote镜像
1.下载Leanote镜像
root@HEJIAJIN-FX506HE:/home/welldone# docker pull axboy/leanote
Using default tag: latest
latest: Pulling from axboy/leanote
23884877105a: Pull complete
bc38caa0f5b9: Pull complete
2910811b6c42: Pull complete
36505266dcc6: Pull complete
a4d269900d94: Pull complete
5e2526abb80a: Pull complete
d3eece1f39ec: Pull complete
358ed78d3204: Pull complete
1a878b8604ae: Pull complete
978c572f0440: Pull complete
35a600ffcf6a: Pull complete
fa9f812cdfe6: Pull complete
7a8109e27110: Pull complete
e7cb12a43d53: Pull complete
98477f6eb1fd: Pull complete
Digest: sha256:9542a462043c9d293e8eda12e1b48ada77ae411121583631c5fa94083a730ef5
Status: Downloaded newer image for axboy/leanote:latest
docker.io/axboy/leanote:latest
2.创建数据目录
创建Leanote容器挂载的数据目录
root@HEJIAJIN-FX506HE:/docker-compose# mkdir -p /docker-compose/leanote/{db,conf,files,upload}
root@HEJIAJIN-FX506HE:/docker-compose# tree leanote/
leanote/
├── conf
├── db
├── files
└── upload
4 directories, 0 files
3.创建Leanote容器
使用docker-cli命令快速创建Leanote容器。
docker run -d -p 9898:9000 \
-e "TZ=Asia/Shanghai"\
--restart=always
-v /docker-compose/leanote/db:/data/db \
-v /docker-compose/leanote/conf/:/data/leanote/conf \
-v /docker-compose/leanote/files:/data/leanote/files \
-v /docker-compose/leanote/upload:/data/leanote/public/upload \
--name leanote \
axboy/leanote
4.使用docker-compose启动一个zyplayer-doc的容器
version: '3.9'
services:
leanote:
image: axboy/leanote
container_name: leanote
volumes:
- '/docker-compose/leanote/upload:/data/leanote/public/upload'
- '/docker-compose/leanote/files:/data/leanote/files'
- '/docker-compose/leanote/conf/:/data/leanote/conf'
- '/docker-compose/leanote/db:/data/db'
restart: always
environment:
- TZ=Asia/Shanghai
ports:
- '9898:9000'
5.查看Leanote容器状态
root@HEJIAJIN-FX506HE:/docker-compose/docker-compose/docker-test# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8ac4caf9d3b axboy/leanote "docker-entrypoint.s…" About a minute ago Up About a minute 27017/tcp, 0.0.0.0:9898->9000/tcp, :::9898->9000/tcp leanote
6.查看Leanote占用资源
检查Leanote容器所在系统资源。
root@HEJIAJIN-FX506HE:/docker-compose/docker-compose/docker-test# docker stats --no-stream leanote
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
a8ac4caf9d3b leanote 0.17% 95.86MiB / 15.35GiB 0.61% 87.8kB / 853kB 0B / 73.9MB 57
六、访问Leanote首页
访问地址http://localhost:9898/
1.首页:2.选择语言为简体中文
3.登录Leanote
管理员账号admin, 密码abc1234.新建笔记
5. 后台管理
6. 设置笔记为公开博客
7. 查看个人博客页面