docker-compose编排工具的安装和使用
1.安装Compose工具 Compose编排工具常用安装方式有两种,一是从GitHub上下载Compose二进制文件后进行安装,二是利用pip安装Compose编排工具。本机选用从GitHub上下载Compose二进制文件后进行安装。
官方下载的慢
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
代理下载地址(很快,本机用代理地址下载)
curl -L https://get.daocloud.io/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
2.测试安装结果
[root@localhost ~]# docker-compose --version
docker-compose version 1.26.2, build unknown
3.编排启动镜像 (1)创建文件目录
mkdir /opt/my_wordpress/
cd /opt/my_wordpress/
(2)编写编排文件
vi docker-compose.yml
把以下内容添加进去
version: '3'
services:
db:
image: mysql:5.7
volumes:
- /data/db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
ports:
- "3306:3306"
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- /data/web_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
(3)启动
docker-compose up -d
#启动方法:docker-compose up
#后台启动方法:docker-compose up -d
#关闭方法:docker-compose down
(4)浏览器上访问http://192.168.5.100:8000,进行wordpress的安装即可      更换主题方法参考:https://www.bilibili.com/video/BV1ue411s7tD 主题地址为:https://gitee.com/mashirozx/Sakura 最后样式如下图,你也可以拥有自己的个人博客了。 
|