flatnotes 是一个自托管的、无数据库的笔记 Web 应用程序,它利用文件夹存储 Markdown 文件。
移动响应式web界面。
原始/所见即所得标记编辑器模式。
高级搜索功能。
注意“标记”功能。
浅色/深色主题。
多个身份验证选项(无、只读、用户名/密码、2FA)。
Restful API。
本次实践为个人测试环境,操作系统版本为centos7.6。
hostname | IP地址 | 操作系统版本 | Docker版本 |
---|---|---|---|
jeven | 192.168.3.166 | centos 7.6 | 20.10.17 |
1.本次实践部署环境为个人测试环境,生产环境请谨慎使用;
2.在Docker环境下成功部署flatnotes笔记工具。
检查Docker服务是否正常运行,确保Docker正常运行。
[root@jeven ~]# 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 Wed 2023-08-23 23:41:16 CST; 1 weeks 1 days ago
Docs: https://docs.docker.com
Main PID: 9562 (dockerd)
Tasks: 50
Memory: 1.4G
CGroup: /system.slice/docker.service
检查Docker版本
[root@jeven ~]# docker version
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:05:12 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:03:33 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0
检查Docker compose版本,确保2.0以上版本。
[[root@jeven ~]# docker compose version
Docker Compose version v2.19.1
从docker hub下载flatnotes镜像
[root@jeven ~]# docker pull dullage/flatnotes
Using default tag: latest
latest: Pulling from dullage/flatnotes
1d5252f66ea9: Pull complete
eefb43356e06: Pull complete
c26db0eb1f01: Pull complete
300843d99304: Pull complete
daddf7df59b6: Pull complete
fd5b7d323a9e: Pull complete
956d12ab1aba: Pull complete
3a27da5a148e: Pull complete
9bc9c825c797: Pull complete
4f4fb700ef54: Pull complete
2dff9aeca767: Pull complete
745990a309e1: Pull complete
cf33157fe535: Pull complete
1f4f074b255f: Pull complete
042bd107273a: Pull complete
Digest: sha256:666b237abff5a16d781ee7f06ccdadef9e42951de3ec320a071407a9e85666ef
Status: Downloaded newer image for dullage/flatnotes:latest
docker.io/dullage/flatnotes:latest
新建挂载目录
mkdir -p /data/flatnotes/data && cd /data/flatnotes/
chmod -R 777 /data/flatnotes/
使用docker-cli命令部署flatnotes笔记工具
[root@jeven flatnotes]# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1
Nl1rQmfg4gsnJfBfsmkXOo7G
docker run -d \
--restart unless-stopped \
--name flatnotes \
-p "28880:8080" \
-v "/data/flatnotes/data:/data" \
-e "FLATNOTES_AUTH_TYPE=password" \
-e "FLATNOTES_USERNAME=admin" \
-e "FLATNOTES_PASSWORD=admin" \
-e "FLATNOTES_SECRET_KEY=Nl1rQmfg4gsnJfBfsmkXOo7G" \
-e "PORT=8080" \
dullage/flatnotes:latest
编辑docker-compose.yaml文件
version: '3'
services:
flatnotes:
image: dullage/flatnotes:latest
container_name: flatnotes
restart: always
ports:
- 28880:8080
volumes:
- /data/flatnotes/data:/data
environment:
- FLATNOTES_AUTH_TYPE=password
- FLATNOTES_USERNAME=admin
- FLATNOTES_PASSWORD=admin
- FLATNOTES_SECRET_KEY=Nl1rQmfg4gsnJfBfsmkXOo7G
- PORT=8080
使用docker compose快速部署flatnotes
[root@jeven flatnotes]# docker compose up -d
[+] Running 2/2
⠿ Network flatnotes_default Created 0.1s
⠿ Container flatnotes Started 0.4s
检查容器状态
[root@jeven flatnotes]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23eebd85b174 dullage/flatnotes:latest "/entrypoint.sh" 13 seconds ago Up 13 seconds 0.0.0.0:28880->8080/tcp, :::28880->8080/tcp flatnotes
检查flatnotes容器日志,确保服务正常运行。
[root@jeven flatnotes]# docker logs flatnotes
Setting up user and group...
Adding group `flatnotes' (GID 1000) ...
Done.
Adding user `flatnotes' ...
Adding new user `flatnotes' (1000) with group `flatnotes' ...
Creating home directory `/home/flatnotes' ...
Copying files from `/etc/skel' ...
Setting file permissions...
WARNING: Breaking changes introduced in version 3.x:
- The port flatnotes uses inside the Docker container has been changed to 8080 (previously 80).
- To accompany the above change, support for the PORT environment variable has been removed.
- The note directory inside the Docker container has moved from /app/data to simply /data.
Starting flatnotes...
2023-09-01 10:22:51 [INFO]: Creating new index
INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
访问地址:http://192.168.3.166:28880
将IP地址替换为自己服务器的IP地址
账号密码为自定义设置的admin/admin
编辑笔记内容,使用markdown格式。
点击预览笔记内容
保存笔记内容
回到首页,可以看到显示刚才编辑保存的笔记。
在挂载目录/data/flatnotes/data上,可以看到刚才编辑保存的笔记文件。
[root@jeven data]# pwd
/data/flatnotes/data
[root@jeven data]# ls -l
total 8
-rw-r--r--. 1 admin admin 5680 Sep 1 18:52 Linux系统之普通用户sudo提权配置.md