使用Compose一键 部署WordPress博客
官网地址:
https://docs.docker.com/samples/wordpress/
1、创建文件夹:
cd my_wordpress/
2、编写docker-compose.yaml
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: {}
3、docker-compose up
-d是后台启动
(如果项目要重新部署打包:docker-compose up --build)
等待完成就可以了
4,输入ip加端口号直接访问
http://192.168.0.107:8000/
(首次进入需要配置相关信息!)