用Docker搭建WordPress
环境准备
CentOS 安装docker
https://yeasy.gitbooks.io/docker_practice/content/install/centos.html
docker-compose安装
https://yeasy.gitbooks.io/docker_practice/content/compose/install.html
创建目录
mkdir -p /srv/docker/wordpress/wp-content
docker-compose
使用docker-compose组织wordpress和mysql,文件代码如下
version: "3"
services:
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- /srv/docker/wordpress/wp-content:/var/www/html/wp-content
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- apinet
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- apinet
networks:
apinet:
volumes:
db_data:
其中volumes 挂载本地存储,数据持久化,
启动
输入命令启动
docker-compose up -d
今天脚踏实地,明天全身轻松