用docker搭建solo个人博客——http

用docker搭建solo个人博客

准备环境:docker、centos7

  • 添加docker环境镜像源
[root@solo ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirror.lzu.edu.cn

[root@solo ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  • 安装docker
[root@solo ~]# yum install docker-ce-18.06.1.ce-3.el7
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirror.lzu.edu.cn
正在解决依赖关系

#若你不喜欢这个版本(自己挑)
[root@solo ~]# yum list all --showduplicates docker-ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirror.lzu.edu.cn
docker-ce-stable                                            | 3.5 kB  00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo                 |   55 B  00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db                 |  60 kB  00:00:00
可安装的软件包
docker-ce.x86_64              17.03.0.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.03.1.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.03.2.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.03.3.ce-1.el7                     docker-ce-stable
docker-ce.x86_64              17.06.0.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.06.1.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.06.2.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.09.0.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.09.1.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.12.0.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              17.12.1.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              18.03.0.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              18.03.1.ce-1.el7.centos              docker-ce-stable
docker-ce.x86_64              18.06.0.ce-3.el7                     docker-ce-stable
docker-ce.x86_64              18.06.1.ce-3.el7                     docker-ce-stable
docker-ce.x86_64              18.06.2.ce-3.el7                     docker-ce-stable
docker-ce.x86_64              18.06.3.ce-3.el7                     docker-ce-stable
docker-ce.x86_64              3:18.09.0-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.1-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.2-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.3-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.4-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.5-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.6-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.7-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.8-3.el7                      docker-ce-stable
docker-ce.x86_64              3:18.09.9-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.0-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.1-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.2-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.3-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.4-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.5-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.6-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.7-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.8-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.9-3.el7                      docker-ce-stable
docker-ce.x86_64              3:19.03.10-3.el7                     docker-ce-stable
docker-ce.x86_64              3:19.03.11-3.el7                     docker-ce-stable
docker-ce.x86_64              3:19.03.12-3.el7                     docker-ce-stable
docker-ce.x86_64              3:19.03.13-3.el7                     docker-ce-stable
docker-ce.x86_64              3:19.03.14-3.el7                     docker-ce-stable
docker-ce.x86_64              3:19.03.15-3.el7                     docker-ce-stable
docker-ce.x86_64              3:20.10.0-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.1-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.2-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.3-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.4-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.5-3.el7                      docker-ce-stable
docker-ce.x86_64              3:20.10.6-3.el7                      docker-ce-stable
  • 开启docker
[root@solo ~]# systemctl start docker
[root@solo ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

  • 拉取solo、mysql、nginx的镜像
[root@solo docker]# docker pull b3log/solo
Using default tag: latest
latest: Pulling from b3log/solo
e7c96db7181b: Pull complete
f910a506b6cb: Pull complete
c2274a1a0e27: Pull complete
d8ba13670e82: Pull complete
d4c6b15fb7b0: Pull complete
bdec41ae5ac4: Pull complete
Digest: sha256:a460e16753a80635c067b3093fe6354ac5324f237585d506f6700ddaa982aea9
Status: Downloaded newer image for b3log/solo:latest
[root@solo docker]# docker pull mysql:5.6
5.6: Pulling from library/mysql
62deabe7a6db: Pull complete
81ba35f9cdf1: Pull complete
5c8f6a545aa1: Pull complete
9ced99c328da: Pull complete
1983b7d65f8f: Pull complete
2fc89d436e20: Pull complete
6cd56cc7fc71: Pull complete
ff26e0e5f66f: Pull complete
cf5586a4456d: Pull complete
53d17e698ea2: Pull complete
b5c84062b3c4: Pull complete
Digest: sha256:5d63153bf35070c230b9d41a754651d99053cbf19a9eec70ebeba926a304761f
Status: Downloaded newer image for mysql:5.6
[root@solo docker]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
f7ec5a41d630: Pull complete
aa1efa14b3bf: Pull complete
b78b95af9b17: Pull complete
c7d6bca2b8dc: Pull complete
cf16cd8e71e0: Pull complete
0241c68333ef: Pull complete
Digest: sha256:75a55d33ecc73c2a242450a9f1cc858499d468f077ea942867e662c247b5e412
Status: Downloaded newer image for nginx:latest

#若你有自己的想法(自行拉取)
[root@solo docker]# docker search +名字

检查安装情况
[root@solo docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
b3log/solo          latest              dfbd9f26c6cd        3 days ago          144MB
nginx               latest              62d49f9bab67        3 days ago          133MB
mysql               5.6                 e26066fd423a        6 days ago          303MB
[root@solo docker]#

  • 启动MySQL(由于我的3306被其他占用所以使用8306)
[root@solo docker]# docker run --name mysql -p 8306:3306 -e MYSQL_ROOT_PASSWORD=123 -d mysql:5.6
541aac1a2ffb94976ac0054f63e96b6ba64c608ee1bc5b6be5589ae0346ac464

  • 进入数据库,创建solo的数据库。
[root@solo docker]# docker exec -it mysql bash
root@541aac1a2ffb:/# 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.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

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> create database solo DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| solo               |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye

关闭你的小防火墙

[root@solo docker]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 六 2021-04-17 12:50:16 CST; 15s ago
     Docs: man:firewalld(1)
  Process: 729 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 729 (code=exited, status=0/SUCCESS)

4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...).
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...).
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...s.
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...s.
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...e.
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...e.
4月 17 12:29:25 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...).
4月 17 12:29:26 solo firewalld[729]: WARNING: COMMAND_FAILED: '/usr/sbin/ipta...).
4月 17 12:50:15 solo systemd[1]: Stopping firewalld - dynamic firewall daemon...
4月 17 12:50:16 solo systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.

启动solo

[root@solo docker]# docker run --detach --name solo --network=host \
> --env RUNTIME_DB="MYSQL" \
> --env JDBC_USERNAME="root" \
> --env JDBC_PASSWORD="123" \
> --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
> --env JDBC_URL="jdbc:mysql://127.0.0.1:8306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"  \
> b3log/solo --listen_port=80 --server_scheme=http --server_host=10.0.0.130 --server_port=80
56466cd661db7485c524b68ffeadadc1924b251f94bee3ad78845fdb673e1dfc

#--server_host=本机地址
#server_port=服务使用的端口(http默认为80,若被占用另辟蹊径)

浏览器:地址+80端口访问

用docker搭建solo个人博客——http_第1张图片
用docker搭建solo个人博客——http_第2张图片

你可能感兴趣的:(Linux,搭建个人博客,docker,solo)