【超详细】Docker快速搭建WordPress博客

环境搭建

linux版本:Centos7.2

Docker安装

软件包安装

yum install -y yum-utils  device-mapper-persistent-data lvm2

设置Docker镜像仓库

wget -O /etc/yum.repos.d/docker.repo https://download.docker.com/linux/centos/docker-ce.repo

更新

yum makecache fast

安装最新版本的docker

yum install docker-ce -y

启动docker并设置开机自启动

systemctl restart docker
systemctl enable docker

查看是否安装成功

[root@liuhang yum.repos.d]# docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:48 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:16:13 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0xxxxxxxxxx [root@liuhang yum.repos.d]# docker versionClient: Docker Engine - Community Version:           20.10.2 API version:       1.41 Go version:        go1.13.15 Git commit:        2291f61 Built:             Mon Dec 28 16:17:48 2020 OS/Arch:           linux/amd64 Context:           default Experimental:      trueServer: Docker Engine - Community Engine:  Version:          20.10.2  API version:      1.41 (minimum version 1.12)  Go version:       go1.13.15  Git commit:       8891c58  Built:            Mon Dec 28 16:16:13 2020  OS/Arch:          linux/amd64  Experimental:     false containerd:  Version:          1.4.3  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b runc:  Version:          1.0.0-rc92  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff docker-init:  Version:          0.19.0  GitCommit:        de40ad0docker version

配置阿里云镜像加速器

mkdir -p /etc/docker
rm -rf /etc/docker/daemon.json
cat >>/etc/docker/daemon.json<

Docker-compose安装

使用国内镜像

curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

授权

chmod 777 /usr/local/bin/docker-compose

查看docker-compose版本

[root@controller ~]# docker-compose version                                     docker-compose version 1.24.0, build 0aa59064
docker-py version: 3.7.2
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018

WordPress博客搭建

创建一个文件夹并进入

[root@controller ~]# mkdir my_wordpress
[root@controller ~]# cd my_wordpress/
[root@controller my_wordpress]# 

编写docker-compose文件

cat >>docker-compose.yml<

启动

docker-compose up

 

访问测试

主机IP:8000

我的主机IP为192.168.100.10

浏览器访问--->>http://192.168.100.10:8000/

【超详细】Docker快速搭建WordPress博客_第1张图片

【超详细】Docker快速搭建WordPress博客_第2张图片

你可能感兴趣的:(linux,dockerfile,docker,docker,linux,centos,wordpress,mysql)