使用docker-compose搭建wordpress非常简单

安装docker

配置docker的yum源

cat >> /etc/yum.repos.d/docker.repo <

yum安装docker

# yum install -y docker
# systemctl start docker
# systemctl enable docker

安装docker-compose

安装

# sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose

写docker-compose的yml文件

version: "3"

services:
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: P@ssW0rd
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress123456
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8888:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress123456
volumes:
  db_data:

启动

# docker-compose up -d

启动过后,在浏览器输入:http://IP:8888 就可以进行博客的创建了。