• 【云原生之Docker实战】使用Docker部署flatnotes笔记工具


    一、flatnotes介绍

    1.1 flatnotes简介

    flatnotes 是一个自托管的、无数据库的笔记 Web 应用程序,它利用文件夹存储 Markdown 文件。

    1.2 flatnotes特点

    • 移动响应式web界面。

    • 原始/所见即所得标记编辑器模式。

    • 高级搜索功能。

    • 注意“标记”功能。

    • 浅色/深色主题。

    • 多个身份验证选项(无、只读、用户名/密码、2FA)。

    • Restful API。

    二、本地环境介绍

    2.1 本地环境规划

    本次实践为个人测试环境,操作系统版本为centos7.6。

    hostnameIP地址操作系统版本Docker版本
    jeven192.168.3.166centos 7.620.10.17

    2.2 本次实践介绍

    1.本次实践部署环境为个人测试环境,生产环境请谨慎使用;
    2.在Docker环境下成功部署flatnotes笔记工具。

    三、本地环境检查

    3.1 检查Docker服务状态

    检查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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    3.2 检查Docker版本

    检查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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    3.3 检查docker compose 版本

    检查Docker compose版本,确保2.0以上版本。

    [[root@jeven ~]# docker compose version
    Docker Compose version v2.19.1
    
    
    • 1
    • 2
    • 3

    四、下载flatnotes镜像

    从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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    五、部署flatnotes笔记工具

    5.1 创建目录

    新建挂载目录

    mkdir -p /data/flatnotes/data   && cd /data/flatnotes/
    
    • 1

    目录授权工作

     chmod -R 777 /data/flatnotes/
    
    • 1

    5.2 使用docker-cli部署

    使用docker-cli命令部署flatnotes笔记工具

    • 生成随机KEY
    [root@jeven flatnotes]# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1
    Nl1rQmfg4gsnJfBfsmkXOo7G
    
    • 1
    • 2
    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    5.3 编辑docker-compose.yaml文件

    编辑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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    5.4 创建flatnotes容器

    使用docker compose快速创建flatnotes容器

    
    [root@jeven flatnotes]# docker compose up -d
    [+] Running 2/2
     ⠿ Network flatnotes_default  Created                                                                                                                                     0.1s
     ⠿ Container flatnotes        Started                                                                                                                                     0.4s
    
    • 1
    • 2
    • 3
    • 4
    • 5

    5.5 检查flatnotes容器状态

    检查容器状态,确保flatnotes容器正常启动。

    [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
    
    • 1
    • 2
    • 3

    5.6 检查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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    六、访问flatnotes

    6.1 进入flatnotes登录页

    访问地址:http://192.168.3.166:28880,将IP替换为自己服务器的IP地址

    在这里插入图片描述

    6.2 访问flatnotes首页

    账号密码为自定义设置的admin/admin

    在这里插入图片描述

    七、flatnotes的基本使用

    7.1 新建笔记

    点击右上角的New",新建笔记。

    在这里插入图片描述

    7.2 编辑笔记内容

    编辑笔记内容,使用markdown格式。

    在这里插入图片描述

    7.3 预览笔记内容

    点击预览笔记内容

    在这里插入图片描述

    7.4 保存笔记内容

    保存笔记内容

    在这里插入图片描述

    7.5 查看首页笔记

    回到首页,可以看到显示刚才编辑保存的笔记。

    在这里插入图片描述

    7.6 查看文件存储

    在挂载目录/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
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    MAC版Gradle构建Spring5.X源码阅读环境
    [计算机入门] 设置日期和时间
    Springboot毕设项目校园靓拍网站7883cjava+VUE+Mybatis+Maven+Mysql+sprnig)
    软件测试这些基本类型你知道吗?
    LTE系统TDD无线帧结构特点
    Mysql中的目录和文件详解
    keyclaok~keycloak存到cookie中的值和session_state
    C++笔记之C语言中常见的文件操作函数汇总
    深度剖析集成学习Xgboost(续)
    小程序源码:全新外卖侠cps5.6全套微信小程序源码下载-多玩法安装简单
  • 原文地址:https://blog.csdn.net/jks212454/article/details/132628349