docker搭建wordpress

1
mkdir wordpress
1
cd wordpress
1
vim docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
version: '3.8'

services:
wordpress:
image: wordpress:latest
container_name: wordpress_app
depends_on:
- db
ports:
- "80:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress_db
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: strong_password
volumes:
- wordpress_data:/var/www/html

db:
image: mysql:5.7
container_name: wordpress_db
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: wordpress_db
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: strong_password
volumes:
- db_data:/var/lib/mysql

volumes:
wordpress_data:
db_data: