使用docker一键搭建WordPress博客

1.环境搭建

环境为:centos7

安装docker:

yum install -y docker

启动docker

systemctl start docker

安装pip

yum -y install epel-release
yum -y install python-pip

使用pip安装docker-compose。

pip install docker-compose

2.一键搭建WordPress

创建wp文件夹,并在wp文件夹新建文件docker-compose.yml

mkdir wp && cd wp && touch docker-compose.yml
docker-compose.yml文件内容
mysql:
    image: mysql:5.7
    environment:
     - MYSQL_ROOT_PASSWORD=123456
     - MYSQL_DATABASE=wordpress
web:
    image: wordpress:4.9.7-php7.0-apache
    links:
     - mysql
    environment:
     - WORDPRESS_DB_PASSWORD=123456
    ports:
     - "0.0.0.0:80:80"
    working_dir: /var/www/html
    volumes:
     - wordpress:/var/www/html
最后运行

docker-compose up -d