Use Docker-Compose to build a Wordpress environment

This article briefly demonstrates how to use Docker-Compose to build a wordpress environment.

Create docker-compose file

First, let’s create a new one file - named: wordpress-compose.yml, the content is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version: "2.0"

services:
wpdb:
image: mysql/mysql-server:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
depends_on:
- wpdb
image: wordpress:latest
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: wpdb:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress

Then execute in the directory where the file is located:

1
docker-compose -f wordpress-compose.yml up -d

In Apple M1

Mainly because the official MySQL mirror of docker does not have an arm64 version, it is enough to switch to MySQL’s own mirror. The modified compose file is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version: "2.0"

services:
wpdb:
image: mysql/mysql-server:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
depends_on:
- wpdb
image: wordpress:latest
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: wpdb:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress

本文标题:Use Docker-Compose to build a Wordpress environment

文章作者:Morning Star

发布时间:2021年06月17日 - 17:06

最后更新:2021年06月22日 - 09:06

原始链接:https://www.mls-tech.info/docker/docker-compose-wordpres_en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。