docker-compose编排wordpress博客
部署wordpress博客环境
编写docker-compose.yml
创建目录并编写服务内容
[root@localhost ~]# mkdir wordpress
[root@localhost ~]# cd wordpress/
[root@localhost wordpress]# vim docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
links:
- db
volumes:
- wp_site:/var/www/html
ports:
- "80:80"
- "443:443"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
wp_site:
运行docker-compose.yml
[root@localhost wordpress]# docker-compose up -d
查看volume
[root@localhost wordpress]# docker volume ls
DRIVER VOLUME NAME
local wordpress_db_data
local wordpress_wp_site
验证博客页面