用docker搭建discuz论坛

使用Discuz和数据库容器搭建论坛服务。

[root@zzz ~]# docker search discuz #查找有无discuz镜像
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tencentci/discuz                     每月或周构建腾讯旗下最新Discuz3.5+,并同步更…                    20
y109/discuz                          The most popular BBS programe in PHP. (http:9                    [OK]
cloud96/discuz                       基于Docker技术,一键安装 Discuz 最新版(X3.4)5
discuzamoy/jd                                                                        1
vimagick/discuz                      An internet forum software written in PHP an…   1                    [OK]
astate/discuz-zh                     基於Discuz! X3.2 Release 20151208繁中UTF-8的…        1
websoft9dev/discuzq                  DiscuzQ from Tencent image                      0
urlos/discuz-sc-utf8                                                                 0
vulfocus/discuz-wooyun_2010_080723   用户名密码:admin:admin                               0
p8361/discuz-ssrf                    discuz-ssrf                                     0
nvidiacn/discuz                                                                      0
urlos/discuzq-env                                                                    0
locoz666666/discuz-x                 Discuz X 容器镜像每日自动构建(基于官方Gitee…                  0
richiemay/discuz                     discuz安装完成后,下次重启容器会自动改名inst…                    0
v7lin/discuz                         discuz                                          0
discuzamoy/jd_scripts                discuzamoy/jd_scripts:latest                    0
boyhack/discuz_ml                    discuz_ml rce 靶机                                0
ttt123shilin/discuz                  采用php-fpm+nginx的方式部署了discuz项目                   0
dockeradminnet/discuz-sc-utf8                                                        0
bachang/discuz2.5                    discuz2.5                                       0
vulfocus/discuzml-cve_2019_13956                                                     0
lycclsltt/discuz                     discuz enviroment, include mysql, php, nginx    0
vulhub/discuz                                                                        0
laalaguer/discuz-x3                                                                  0
nw4869/discuz                        docker run -it --rm nw4869/discuz crack.sh <0                    [OK]
[root@zzz ~]# docker pull tencentci/discuz  #拉取discuz镜像:tencentci/discuz
Using default tag: latest
latest: Pulling from tencentci/discuz
d599a449871e: Pull complete
1a363f133ddd: Pull complete
dd6ffd5f60d7: Pull complete
515e48bcd87c: Pull complete
c6f3d43db193: Pull complete
f1c6f8e807f6: Pull complete
65d8fe3b5a08: Pull complete
80429671c76c: Pull complete
053b8d72a5a3: Pull complete
deb7baf580dc: Pull complete
8201b8a6c5c5: Pull complete
689e9b2c72d1: Pull complete
50557b0d5d8a: Pull complete
9beee0a5f923: Pull complete
97139e44b116: Pull complete
563f74e42351: Pull complete
Digest: sha256:b2d9f7cfde768d844fef738a6e1bb4dc5675bddf2565f296d7b76d1eabfd0218
Status: Downloaded newer image for tencentci/discuz:latest
docker.io/tencentci/discuz:latest
[root@zzz ~]# docker images  #查看镜像列表
REPOSITORY         TAG       IMAGE ID       CREATED         SIZE
nginx              latest    605c77e624dd   7 months ago    141MB
php                latest    13b9b1961ba3   8 months ago    484MB
httpd              latest    dabbfbe0c57b   8 months ago    144MB
test/httpd         v1        dabbfbe0c57b   8 months ago    144MB
alpine             latest    c059bfaa849c   8 months ago    5.59MB
ubuntu             latest    ba6acccedd29   10 months ago   72.8MB
hello-world        latest    feb5d9fea6a5   10 months ago   13.3kB
tencentci/discuz   latest    4833f513a33c   13 months ago   463MB
[root@zzz ~]# docker run -P -d tencentci/discuz  #启动discuz
fd5450068d4af07ae6045deb97fc75c226ec75be4e5228488cdb060d263d01fc
[root@zzz ~]# docker ps -a  #查看运行容器,tencentci/discuz端口号49154
CONTAINER ID   IMAGE              COMMAND                  CREATED          STATUS                    PORTS                                                                                NAMES
fd5450068d4a   tencentci/discuz   "docker-php-entrypoi…"   18 seconds ago   Up 17 seconds             0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp   xenodochial_jennings
af87fa529103   httpd              "httpd-foreground"       34 hours ago     Exited (0) 32 hours ago                                                                                        web1
1443f5c0a46e   nginx              "/docker-entrypoint.…"   34 hours ago     Exited (0) 32 hours ago                                                                                        web
d41bcc87ab2d   ubuntu             "bash"                   35 hours ago     Exited (0) 35 hours ago                                                                                        vigorous_johnson
15b5646d31de   hello-world        "/hello"                 35 hours ago     Exited (0) 35 hours ago                                                                                        elated_hypatia
f18ae09bbeab   hello-world        "/hello"                 2 days ago       Exited (0) 2 days ago                                                                                          sad_mcclintock
[root@zzz ~]# docker search php
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
php                                  While designed for web development, the PHP …   6722      [OK]
composer                             Composer is a dependency manager written in902       [OK]
adminer                              Database management in a single PHP file.       746       [OK]
phpmyadmin                           phpMyAdmin - A web interface for MySQL and M…   606       [OK]
mediawiki                            MediaWiki is a free software open source wik…   440       [OK]
webdevops/php-nginx                  Nginx with PHP-FPM                              233                  [OK]
php-zendserver                       Zend Server - the integrated PHP application…   201       [OK]
yourls                               YOURLS is a set of PHP scripts that will all191       [OK]
bitnami/php-fpm                      Bitnami PHP-FPM Docker Image                    150                  [OK]
webdevops/php-apache-dev             PHP with Apache for Development (eg. with xd…   147                  [OK]
webdevops/php-apache                 Apache with PHP-FPM (based on webdevops/php)    127                  [OK]
bitnami/phpmyadmin                   Bitnami Docker Image for phpMyAdmin             37                   [OK]
circleci/php                         CircleCI images for PHP                         35
webdevops/php-nginx-dev              PHP with Nginx for Development (eg. with xde…   28                   [OK]
bitnami/phpbb                        Bitnami Docker Image for phpBB                  25                   [OK]
webdevops/php                        PHP (FPM and CLI) service container             24                   [OK]
bitnami/phppgadmin                                                                   10
phpcollab/phpcollab                  phpCollab is an open source internet-enabled…   7
newrelic/php-daemon                  New Relic’s PHP daemon gathers APM data from4
webdevops/php-dev                    PHP with debugging tools (eg. xdebug)           4                    [OK]
cimg/php                                                                             2
pipelinecomponents/php-codesniffer   PHP Codesniffer in a container for gitlab-ci    1
okteto/php                                                                           0
pipelinecomponents/php-linter        PHP parallel linter in a container for gitla…   0
clearlinux/php-fpm                   PHP FastCGI Process Manager implementation w…   0
[root@zzz ~]# docker pull php
Using default tag: latest
latest: Pulling from library/php
a2abf6c4d29d: Already exists
c5608244554d: Pull complete
2d07066487a0: Pull complete
1b6dfaf1958c: Pull complete
40f5e6ee20ce: Pull complete
718b027f9905: Pull complete
3bf01f3e893c: Pull complete
af85a153f85f: Pull complete
e052a88c20f6: Pull complete
Digest: sha256:444ba13f11741642a2692430f6678d47fb028442160ec9a5cfa9da7d3c0a9e07
Status: Downloaded newer image for php:latest
docker.io/library/php:latest

浏览器访问192.168.240.130:49254到达论坛安装页面。
在这里插入图片描述

[root@zzz ~]# docker ps -a 
CONTAINER ID   IMAGE              COMMAND                  CREATED          STATUS                    PORTS                                                                                NAMES
fd5450068d4a   tencentci/discuz   "docker-php-entrypoi…"   11 minutes ago   Up 11 minutes             0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp   xenodochial_jennings
af87fa529103   httpd              "httpd-foreground"       34 hours ago     Exited (0) 33 hours ago                                                                                        web1
1443f5c0a46e   nginx              "/docker-entrypoint.…"   34 hours ago     Exited (0) 33 hours ago                                                                                        web
d41bcc87ab2d   ubuntu             "bash"                   35 hours ago     Exited (0) 35 hours ago                                                                                        vigorous_johnson
15b5646d31de   hello-world        "/hello"                 35 hours ago     Exited (0) 35 hours ago                                                                                        elated_hypatia
f18ae09bbeab   hello-world        "/hello"                 2 days ago       Exited (0) 2 days ago                                                                                          sad_mcclintock
[root@zzz ~]# docker top xenodochial_jennings  #查看容器中运行的xenodochial_jennings信息
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                1640                1620                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1673                1640                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1674                1640                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1675                1640                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1676                1640                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1677                1640                0                   21:14               ?                   00:00:00            apache2 -DFOREGROUND
33                  1685                1640                0                   21:20               ?                   00:00:00            apache2 -DFOREGROUND
[root@zzz ~]# yum install mariadb-server -y #安装mariadb-server
[root@zzz ~]# systemctl start mariadb #启动mariadb服务
[root@zzz ~]# ss -lntup | grep 3306 #3306是mariadb的端口号
tcp    LISTEN     0      50        *:3306                  *:*                   users:(("mysqld",pid=2085,fd=14))
[root@zzz ~]# mysql_secure_installation
[root@zzz ~]# mysql -u root -p #用root用户的身份进入数据库,输入密码
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;  #查看现有数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> create database forum;  #创建一个数据库forum
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;  #查看现有数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| forum              |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> use forum;  
Database changed
MariaDB [forum]> show tables;
Empty set (0.00 sec)

MariaDB [forum]> exit
Bye

创建数据库,输入基本信息如下:

在这里插入图片描述
输入完成后点击下一步跳转页面,显示“不允许访问”。
在这里插入图片描述

[root@zzz ~]# docker exec xenodochial_jennings hostname -I
172.17.0.2
[root@zzz ~]# mysql -uroot -p   
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on *.* to 'root@%' identified by 'red123' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> show tables ;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)
MariaDB [mysql]> select host,user,password from user ;
+-----------+--------+-------------------------------------------+
| host      | user   | password                                  |
+-----------+--------+-------------------------------------------+
| localhost | root   | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| 127.0.0.1 | root   | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| ::1       | root   | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| %         | root@% | *2E959EACF66183C8645178056D6A0252E29D29B2 |
+-----------+--------+-------------------------------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> flush privileges;  #刷新权限表
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> exit
Bye
[root@zzz ~]# mysql -uroot -pmysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
MariaDB [mysql]> grant all on *.* to root@'192.168.240.130' identified by 'red123' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> grant all on *.* to root@'192.168.240.130' identified by 'red123' ;  #授权

Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> update user set user="root" where host='%'
    -> ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
MariaDB [mysql]> select user,host,password from user;
+------+-----------------+-------------------------------------------+
| user | host            | password                                  |
+------+-----------------+-------------------------------------------+
| root | localhost       | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| root | 127.0.0.1       | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| root | ::1             | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| root | 192.168.240.130 | *2E959EACF66183C8645178056D6A0252E29D29B2 |
| root | %               | *2E959EACF66183C8645178056D6A0252E29D29B2 |
+------+-----------------+-------------------------------------------+
5 rows in set (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| forum              |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@zzz ~]# docker ps -a
CONTAINER ID   IMAGE              COMMAND                  CREATED             STATUS                    PORTS                                                                                NAMES
fd5450068d4a   tencentci/discuz   "docker-php-entrypoi…"   About an hour ago   Up About an hour          0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp   xenodochial_jennings
af87fa529103   httpd              "httpd-foreground"       35 hours ago        Exited (0) 34 hours ago                                                                                        web1
1443f5c0a46e   nginx              "/docker-entrypoint.…"   35 hours ago        Exited (0) 34 hours ago                                                                                        web
d41bcc87ab2d   ubuntu             "bash"                   37 hours ago        Exited (0) 37 hours ago                                                                                        vigorous_johnson
15b5646d31de   hello-world        "/hello"                 37 hours ago        Exited (0) 37 hours ago                                                                                        elated_hypatia
f18ae09bbeab   hello-world        "/hello"                 2 days ago          Exited (0) 2 days ago                                                                                          sad_mcclintock

在这里插入图片描述

在这里插入图片描述


版权声明:本文为weixin_44610118原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。