环境搭建

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<<eof
{
  "registry-mirrors": ["https://5ke62mgb.mirror.aliyuncs.com"]
}
eof
systemctl daemon-reload
systemctl restart docker

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<<eof
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
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}
eof

启动

docker-compose up

 

访问测试

主机IP:8000

我的主机IP为192.168.100.10

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

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐