Centos7下实现docker + wordpress 安装
2019-08-15 16:11 软件测试汪 阅读(659) 评论(0) 编辑 收藏 举报一、Docker CE 安装
检查是否安装过旧的版本
如果系统安装旧版本Docker需要先卸载,命令如下:
[root@localhost Wordpresss]sudo yum remove docker \
> docker-common \
> docker-selinux \
> docker-engine
安装以下的依赖包
[root@localhost Wordpresss]sudo yum install -y yum-utils \
> device-mapper-persistent-data \
> lvm2
配置Docker CE仓库
[root@localhost Wordpresss]sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
安装docker CE
[root@localhost Wordpresss]sudo yum install docker-ce
启动docker
[root@localhost Wordpresss]sudo systemctl start docker
查看docker版本
[root@localhost Wordpresss]docker version
二、安装docker-compose
安装最新版本的docker-compose
[root@localhost Wordpresss]curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
对二进制文件应用可执行权限
[root@localhost Wordpresss]chmod +x /usr/local/bin/docker-compose
查看docker-compose版本
[root@localhost Wordpresss]docker-compose version
三、使用docker-compose安装wordpress
创建一个空的项目目录
[root@localhost Wordpresss]mkdir /usr/local/wordpress
切换到目录
[root@localhost Wordpresss]cd /usr/local/wordpress
创建docker-compose.yml启动WordPress博客的文件, 并创建一个独立MySQL实例,并使用卷挂接来实现数据持久性
vi docker-compose.yml
# docker-compose.yml
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
建立项目
[root@localhost Wordpresss]docker-compose up