推荐文章:
【合集】Docker
创建目录
mkdir ~/wordpress
部署MySQL
mkdir ~/wordpress/mysql cd ~/wordpress/mysql
1
2
3
4
5
6
7
8
9
10
11
|
docker run -id \
-p 3307:3306 \
--name=mysql4WP \
--network common-network \
--restart=always \
-e TZ=UTC \
-v $PWD/conf:/etc/mysql/conf.d \
-v $PWD/logs:/logs \
-v $PWD/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root \
mysql:5.6
|
创建数据库wordpress
自动拉取镜像并启动容器
1
2
3
4
5
6
7
8
9
10
|
docker run -d --name wordpress \
-e TZ="UTC" \
-e WORDPRESS_DB_HOST=101.43.123.47:3307 \
-e WORDPRESS_DB_USER=root \
-e WORDPRESS_DB_PASSWORD=root \
-e WORDPRESS_DB_NAME=wordpress \
-v ~/wordpress/www:/var/www/html \
-p 1080:80 \
--restart=always \
wordpress
|
参数说明:
- WORDPRESS_DB_HOST:mysql的IP+端口
- WORDPRESS_DB_USER:mysq用户名
- WORDPRESS_DB_PASSWORD:mysql密码
- WORDPRESS_DB_NAME:数据库名,默认是wordpress
- -p 1080:80 是指宿主机的1080端口映射容器的80端口,容器内端口80不要修改
- restart=always 随docker的启动而启动
运行完可以查看日志
docker logs --tail 10 wordpress | grep info
打开地址安装:https://www.zxalive.com/wp-admin/setup-config.php
后台管理地址 http://127.0.0.1:80/wp-admin