-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
34 lines (31 loc) · 1.23 KB
/
docker-compose.yaml
File metadata and controls
34 lines (31 loc) · 1.23 KB
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:
db:
image: mysql:8.0
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress # MySQL root 密码
MYSQL_DATABASE: wordpress # WordPress 数据库名
MYSQL_USER: wordpress # WordPress 数据库用户
MYSQL_PASSWORD: wordpress # WordPress 数据库密码
volumes:
- ./db_data:/var/lib/mysql # 持久化 MySQL 数据
ports:
- "43306:3306" # 暴露 MySQL 端口(宿主机:容器)
wordpress:
depends_on:
- db
image: wordpress:latest
restart: always
ports:
- "40080:80" # HTTP 端口映射(宿主机访问 WordPress:http://localhost:40080)
- "40022:22" # SSH 端口映射(SSH 连接容器:ssh root@localhost -p 40022)
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
- ./wordpress_data:/var/www/html # 持久化 WordPress 数据
- ./entrypoint.sh:/usr/local/bin/entrypoint.sh # 挂载自定义 entrypoint 脚本
entrypoint: /usr/local/bin/entrypoint.sh # 使用自定义 entrypoint 启动 SSH + WordPress