通过docker-compose安装wordpress

作者:吴业亮

博客:wuyeliang.blog.csdn.net

一、安装docker
1、配置源

cat </etc/yum.repos.d/repo.repo
[repo]
name=repo
baseurl = https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7/x86_64/stable/
enabled=1
gpgcheck=0
END

2、安装docker-ce

yum install docker-ce

3、启动服务和设置开机启动

# service docker start
# chkconfig docker on

4、配置国内源

# mkdir -p /etc/docker
#  tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://***.mirror.aliyuncs.com"]
}
EOF

# service docker restart

二、安装docker-compose

# yum install epel* -y
# yum install  docker-compose -y

三、安装wordpress
1、创建 stack.yml

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

2、启动

docker-compose -f stack.yml up

3、登录web

http://ip:8080

通过docker-compose安装wordpress_第1张图片
通过docker-compose安装wordpress_第2张图片
通过docker-compose安装wordpress_第3张图片
通过docker-compose安装wordpress_第4张图片

你可能感兴趣的:(docker)