使用docker-compose 搭建WordPress博客

大家好,今天给大家分享一下使用docker-compose 搭建WordPress博客

首先,请跟着我的上一篇博客安装docker-compose的环境

就是这个

查看版本

这就是没问题的

[root@localhost composetest]# docker-compose version
docker-compose version 1.29.1, build c34c88b2
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019
[root@localhost composetest]# 

随便进入一个目录

[root@localhost composetest]# cd /home/

新建一个目录

[root@localhost home]# mkdir my_wordpree/

进入这个目录

[root@localhost home]# cd my_wordpree/

编写docker-compose.yml 文件

[root@localhost my_wordpree]# vim docker-compose.yml
version: "3.9"
    
services:
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
volumes:
  db_data: {
   }
  wordpress_data: {
   }

保存退出

启动

[root@localhost my_wordpree]# docker-compose up      

它会自动的下载需要的镜像的
这个时间可能会比较长

Creating network "my_wordpree_default" with the default driver
Creating volume "my_wordpree_db_data" with default driver
Creating volume "my_wordpree_wordpress_data" with default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
72a69066d2fe: Pull complete
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
0ceb82207cd7: Pull complete
37f2405cae96: Pull completeMB/108.6MBB3: Downloading [========>                                          ]     9
70deed891d42: Download complete^CGracefully stopping... (press Ctrl+C again to force)
[root@localhost my_wordpree]# docker-compose up
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
72a69066d2fe: Pull complete
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
0ceb82207cd7: Pull complete
37f2405cae96: Pull complete
e2482e017e53: Pull complete
70deed891d42: Pull complete
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
a2abf6c4d29d: Already exists
c5608244554d: Pull complete
2d07066487a0: Pull complete
1b6dfaf1958c: Pull complete
32c5e6a60073: Pull complete
90cf855b27cc: Pull complete
8b0f1068c586: Pull complete
5355461305e8: Pull complete
ad1eec592342: Pull complete
e03fbc76cb78: Pull complete
1f5796e48b39: Pull complete
72fbe8e1d4e7: Pull complete
96edece66175: Pull complete
5f46f0743de2: Pull complete
c9f9671a5e1f: Pull complete
3f543dcd35b1: Pull complete
c88e21a0c2a0: Pull complete
964b4457a910: Pull complete
0d55fb9a64ef: Pull complete
fb009ff7c567: Pull complete
4f058a67a50d: Pull complete
Digest: sha256:fc33b796b04162a0db2e9ea9b4c361a07058b21597b1317ad9ab3ea4593de241
Status: Downloaded newer image for wordpress:latest
Creating my_wordpree_db_1 ... done
Creating my_wordpree_wordpress_1 ... done
Attaching to my_wordpree_db_1, my_wordpree_wordpress_1

这一推都是他后台运行的日志

db_1         | 2022-06-02 08:22:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
db_1         | 2022-06-02 08:22:57+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1         | 2022-06-02 08:22:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
db_1         | 2022-06-02 08:22:57+00:00 [Note] [Entrypoint]: Initializing database files
db_1         | 2022-06-02T08:22:57.622164Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1         | 2022-06-02T08:23:33.110360Z 0 [Warning] InnoDB: New log files created, LSN=45790
db_1         | 2022-06-02T08:23:33.149546Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
db_1         | 2022-06-02T08:23:33.205921Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4a825bda-e24d-11ec-96ba-0242ac130002.
db_1         | 2022-06-02T08:23:33.206762Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
wordpress_1  | WordPress not found in /var/www/html - copying now...
wordpress_1  | Complete! WordPress has been successfully copied to /var/www/html
wordpress_1  | No 'wp-config.php' found in /var/www/html, but 'WORDPRESS_...' variables supplied; copying 'wp-config-docker.php' (WORDPRESS_DB_HOST WORDPRESS_DB_NAME WORDPRESS_DB_PASSWORD WORDPRESS_DB_USER)
db_1         | 2022-06-02T08:23:34.266129Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
db_1         | 2022-06-02T08:23:34.266148Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
db_1         | 2022-06-02T08:23:34.266559Z 0 [Warning] CA certificate ca.pem is self signed.
db_1         | 2022-06-02T08:23:34.424496Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | [Thu Jun 02 08:23:37.160075 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.51 (Debian) PHP/7.4.27 configured -- resuming normal operations
wordpress_1  | [Thu Jun 02 08:23:37.160135 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
db_1         | 2022-06-02 08:23:41+00:00 [Note] [Entrypoint]: Database files initialized
db_1         | 2022-06-02 08:23:41+00:00 [Note] [Entrypoint]: Starting temporary server
db_1         | 2022-06-02 08:23:41+00:00 [Note] [Entrypoint]: Waiting for server startup
db_1         | 2022-06-02T08:23:46.760440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1         | 2022-06-02T08:23:46.762338Z 0 [Note] mysqld (mysqld 5.7.36) starting as process 76 ...
db_1         | 2022-06-02T08:23:46.764755Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1         | 2022-06-02T08:23:46.764767Z 
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

思诚代码块

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值