码迷,mamicode.com
首页 > 其他好文 > 详细

docker-compose (单机版的容器编排工具)

时间:2019-12-05 22:31:38      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:pre   serve   mes   some   database   user   restart   doc   root   

类似于ansible剧本 yml 格式
要使用这个编排工具,必须先安装
yum install -y docker-compose

cd wordpress/
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

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
       - /data/web_data:/var/www/html
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress

###############

在含有docker-compose.yml的目录下执行
docker-compose up -d

访问网页,检查

使用docker-compose编排方式,安装zabbix

vim docker-compose.yml
################
version: '3'

services:
   mysql-server:
     image: mysql:5.7
     restart: always
     command: --character-set-server=utf8 --collation-server=utf8_bin
     environment:
       MYSQL_ROOT_PASSWORD: root_pwd
       MYSQL_DATABASE: zabbix
       MYSQL_USER: zabbix
       MYSQL_PASSWORD: zabbix_pwd
   
   zabbix-java-gateway:
     image: zabbix/zabbix-java-gateway:latest
     restart: always 

   zabbix-server:
     depends_on:
       - mysql-server
       - zabbix-java-gateway
     image: zabbix/zabbix-server-mysql:latest
     ports:
       - "10051:10051"
     restart: always
     environment:
       DB_SERVER_HOST: mysql-server 
       MYSQL_DATABASE: zabbix 
       MYSQL_USER: zabbix 
       MYSQL_PASSWORD: zabbix_pwd 
       MYSQL_ROOT_PASSWORD: root_pwd 
       ZBX_JAVAGATEWAY: zabbix-java-gateway 

   zabbix-web:
     depends_on:
       - mysql-server
       - zabbix-server
     image: zabbix/zabbix-web-nginx-mysql:latest
     ports:
       - "80:80"
     restart: always
     environment:
       DB_SERVER_HOST: mysql-server 
       MYSQL_DATABASE: zabbix 
       MYSQL_USER: zabbix 
       MYSQL_PASSWORD: zabbix_pwd 
       MYSQL_ROOT_PASSWORD: root_pwd
################

在含有docker-compose.yml的目录下执行
docker-compose up -d

访问网页,检查

docker-compose (单机版的容器编排工具)

标签:pre   serve   mes   some   database   user   restart   doc   root   

原文地址:https://www.cnblogs.com/yangxiaoni/p/11991878.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!