云原生之Docker实战使用Docker部署Solo个人博客站点

Posted 江湖有缘

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了云原生之Docker实战使用Docker部署Solo个人博客站点相关的知识,希望对你有一定的参考价值。

【云原生之Docker实战】使用Docker部署Solo个人博客站点

一、卷首语

中秋之《乡愁》
临近中秋佳节,提前祝大家中秋快乐,阖家团圆!
在每个奋笔疾书的日子里,挥之不去的是那份乡愁!
这是我最喜欢的诗歌之一,是每个在外游子浓浓的思乡之情!

乡愁
席慕容
故乡的歌是一支清远的笛
总在有月亮的晚上响起
故乡的面貌 却是一种模糊的怅望
仿佛雾里的挥手别离
离别後
乡愁是一棵没有年轮的树
永不老去

二、Solo介绍

1.Solo简介

Solo 是一款小而美的开源博客系统,专为程序员设计。

2.Solo功能

1.Markdown 编辑器支持三种编辑模式:所见即所得 / 即时渲染 / 分屏预览。
2.标签聚合分类。
3.自定义导航链接。
4.随机文章 / 相关文章 / 置顶 / 更新提醒。
5.自定义文章永久链接 / 签名档。
6.配置站点 SEO 参数 / 公告 / 页脚。
7.代码高亮 / 数学公式 / 流程图 / 五线谱。
8.多皮肤,多端适配。
9.多语言 / 国际化。
10.友情链接管理
11.多用户写作,团队博客。
12.Hexo / Jekyll / Markdown 导入。
13.SQL / JSON / Markdown 导出。
14.Atom / RSS / Sitemap。
15.CDN 静态资源分离,可配置 jsDelivr CDN 分发。
16.拉取 GitHub 仓库和自动备份。
17.内置 HTTPS+CDN 文件存储。
18.支持生成导出静态站点,用于发布 GitHub Pages。

三、检查本地docker环境

1.检查docker服务状态

[root@node ~]# 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 Fri 2022-08-26 00:54:36 CST; 2 days ago
     Docs: https://docs.docker.com
 Main PID: 11742 (dockerd)
    Tasks: 38
   Memory: 1.1G
   CGroup: /system.slice/docker.service
           ├─11742 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─21262 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3876 -container-ip 172.18.0.2 -container-port 3306
           ├─21268 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3876 -container-ip 172.18.0.2 -container-port 3306
           ├─21282 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.18.0.3 -container-port 80
           └─21289 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.18.0.3 -container-port 80

Aug 26 00:54:35 node dockerd[11742]: time="2022-08-26T00:54:35.636687869+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0....IP address"
Aug 26 00:54:35 node dockerd[11742]: time="2022-08-26T00:54:35.712366254+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 26 00:54:35 node dockerd[11742]: time="2022-08-26T00:54:35.791017533+08:00" level=info msg="Loading containers: done."
Aug 26 00:54:36 node dockerd[11742]: time="2022-08-26T00:54:36.035620267+08:00" level=info msg="Docker daemon" commit=a89b842 graphdriver(s)=overlay2 version=20.10.17
Aug 26 00:54:36 node dockerd[11742]: time="2022-08-26T00:54:36.036700746+08:00" level=info msg="Daemon has completed initialization"
Aug 26 00:54:36 node systemd[1]: Started Docker Application Container Engine.
Aug 26 00:54:36 node dockerd[11742]: time="2022-08-26T00:54:36.205480897+08:00" level=info msg="API listen on /var/run/docker.sock"
Aug 26 01:33:42 node dockerd[11742]: time="2022-08-26T01:33:42.599199902+08:00" level=info msg="Firewalld: interface br-e0fbf9e9f302 already part of docker zone, returning"
Aug 26 01:33:46 node dockerd[11742]: time="2022-08-26T01:33:46+08:00" level=info msg="Firewalld: docker zone already exists, returning"
Aug 26 01:33:46 node dockerd[11742]: time="2022-08-26T01:33:46+08:00" level=info msg="Firewalld: docker zone already exists, returning"
Hint: Some lines were ellipsized, use -l to show in full.

2.检查docker配置信息

[root@node ~]# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., v2.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 3
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.62GiB
 Name: node
 ID: EIOB:6IAO:NQTR:AJBA:O6KS:SNWP:JEDK:GXBG:55FP:iosK:WRH3:QOAU
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://sp4mg57h.mirror.aliyuncs.com/
 Live Restore Enabled: false

WARNING: IPv4 forwarding is disabled

3.开启IPv4 forwarding

[root@node ~]# echo "net.ipv4.ip_forward=1" >>  /etc/sysctl.conf
[root@node ~]# systemctl restart network
[root@node ~]#  sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

四、安装docker-compose

1.下载docker-compose二进制包

 curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
[root@node docker-compose]#  curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0    362      0  0:00:01  0:00:01 --:--:--   362
100 16.2M  100 16.2M    0     0  8568k      0  0:00:01  0:00:01 --:--:-- 8568k

2.给文件增加执行权限

chmod +x /usr/local/bin/docker-compose 

3.检查docker-compose版本

[root@node docker-compose]# docker-compose version
docker-compose version 1.25.0, build 0a186604
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

五、下载solo镜像

[root@node ~]# docker pull   b3log/solo
Using default tag: latest
latest: Pulling from b3log/solo
e7c96db7181b: Pull complete 
f910a506b6cb: Pull complete 
c2274a1a0e27: Pull complete 
fb14f7edaadd: Pull complete 
4c5a70d63309: Pull complete 
936318baa0fc: Pull complete 
Digest: sha256:dc1a208824d0c90f5bc64d36d8e9635ea9355f23e45c9c1f6afe5a7c59fcf14f
Status: Downloaded newer image for b3log/solo:latest
docker.io/b3log/solo:latest


六、使用docker命令方式安装Solo

docker run --detach --name solo --network=host \\
    --env RUNTIME_DB="mysql" \\
    --env JDBC_USERNAME="root" \\
    --env JDBC_PASSWORD="123456" \\
    --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \\
    --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true" \\
    b3log/solo --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=



七、使用docker-compose部署Solo

1.编辑docker-compose.yaml文件


[root@node solo]# cat docker-compose.yaml 
version: '3'
services:
   mysql:
        image: mysql:5.6
        restart: always
        ports:
          - 3232:3306
        environment:
           MYSQL_DATABASE: solo
           MYSQL_USER: solo
           MYSQL_PASSWORD: solo
           MYSQL_ROOT_PASSWORD: solo
        volumes:
           - /data/solo/mysql:/var/lib/mysql
        networks:
            - myweb-net
   solo:
        container_name: solo
        image:  b3log/solo
        restart: always
        ports:
          - 8078:8080
        environment:
          RUNTIME_DB: MYSQL
          JDBC_USERNAME: root
          JDBC_PASSWORD: solo
          JDBC_DRIVER: "com.mysql.cj.jdbc.Driver"
          JDBC_URL: "jdbc:mysql://192.168.3.166:3232/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"
        networks:
          - myweb-net
        command: --listen_port=8080 --server_scheme=http 
#        volumes:
#          -  /data/solo/skins/:/opt/solo/skins/
            

volumes:
   wordpress:
   db:
networks:
   myweb-net:
        driver: bridge

2.创建Solo容器

[root@node solo]# docker-compose up -d
Creating network "solo_myweb-net" with driver "bridge"
Creating solo         ... done
Creating solo_mysql_1 ... done


3.查看Solo容器状态

[root@node solo]# docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS          PORTS                                       NAMES
36d0bdc0a04e   mysql:5.6         "docker-entrypoint.s…"   19 minutes ago   Up 19 minutes   0.0.0.0:3232->3306/tcp, :::3232->3306/tcp   solo_mysql_1
e287abced896   b3log/solo        "java -cp lib/*:. or…"   19 minutes ago   Up 19 minutes   0.0.0.0:8078->8080/tcp, :::8078->8080/tcp   solo

4.查看Solo容器日志

[root@node solo]# docker logs solo |tail -n 5
[INFO ]-[2022-08-28 22:53:10]-[org.b3log.solo.Server:255]: Solo is booting [ver=4.3.1, os=Linux, isDocker=true, inJar=false, luteAvailable=false, pid=1, runtimeDatabase=MYSQL, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:mysql://192.168.3.166:3232/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true]
[INFO ]-[2022-08-28 22:53:10]-[org.b3log.solo.service.InitService:177]: It's your first time setup Solo, initialize tables in database [MYSQL]
[WARN ]-[2022-08-28 22:53:10]-[org.b3log.solo.service.InitService:150]: Solo has not been initialized, please open your browser to init Solo
[INFO ]-[2022-08-28 22:54:33]-[org.b3log.solo.util.Skins:70]: Loaded template from directory [/opt/solo/]
[INFO ]-[2022-08-28 23:08:12]-[org.b3log.solo.processor.OAuthProcessor:205]: Logged in [name=awk-m618, remoteAddr=192.168.3.11] with oauth


八、登录Solo的web界面

1.登录Solo页面

2.注册官方账号登录

3.重新访问Solo

九、Solo的基本使用

1.访问后台管理

2.主题皮肤管理

3.查看更换后主题的主页

十、测试博文效果

1.Bubble皮肤风格下的效果

2.metro-hot皮肤风格下的效果

3.Finding皮肤风格下的效果

4.nijigen皮肤风格下的效果

以上是关于云原生之Docker实战使用Docker部署Solo个人博客站点的主要内容,如果未能解决你的问题,请参考以下文章

云原生之Docker实战使用Docker部署Cloudreve公有云文件系统

云原生之Docker实战使用docker部署Ghost个人博客系统

云原生之Docker实战使用Docker部署jpress开源网站

云原生之Docker实战使用Docker部署speedtest测速平台

云原生之Docker实战使用Docker部署部署DoClever开源接口管理平台

云原生之Docker实战使用Docker部署NodeBB社区平台