使用docker-compose搭建zabbix

简介

欢迎star fork这个项目

https://github.com/bboysoulcn/awesome-dockercompose

之后我会上传并且完善更多的compose文件来方便大家搭建各种各样的环境

今天我们来说怎么使用这个项目搭建zabbix

操作

首先我们clone下这个项目

git clone https://github.com/bboysoulcn/awesome-dockercompose.git

cd awesome-dockercompose/zabbix

之后看下我们的compose文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
version: "3"
services:
zabbix-server:
image: "zabbix/zabbix-server-mysql:centos-4.0.4"
container_name: "zabbix-server"
restart: "always"
environment:
- "DB_SERVER_HOST=zabbix-db"
- "MYSQL_USER=root"
- "MYSQL_PASSWORD="
#- "DB_SERVER_PORT="
#- "MYSQL_DATABASE="
volumes:
- "zabbix-server-data:/var/lib/zabbix/"
depends_on:
- "zabbix-db"
ports:
- "10051:10051"


zabbix-web:
image: "zabbix/zabbix-web-nginx-mysql:centos-4.0.4"
container_name: "zabbix-web"
restart: "always"
environment:
- "DB_SERVER_HOST=zabbix-db"
- "MYSQL_USER=root"
- "MYSQL_PASSWORD="
- "ZBX_SERVER_HOST=zabbix-server"
- "PHP_TZ=Asia/Shanghai "
#- "ZBX_SERVER_PORT="
#- "DB_SERVER_PORT="
#- "MYSQL_DATABASE="
#- "ZBX_SERVER_NAME="
depends_on:
- "zabbix-server"
- "zabbix-db"
ports:
- "8082:80"

zabbix-db:
image: "mariadb:10.2.22"
container_name: "zabbix-db"
restart: "always"
environment:
- "MYSQL_ROOT_PASSWORD="
- "MYSQL_DATABASE=zabbix"
#- "MYSQL_USER="
#- "MYSQL_PASSWORD="
#- "MYSQL_ALLOW_EMPTY_PASSWORD="
#- "MYSQL_RANDOM_ROOT_PASSWORD="
#ports:
# - "3306:3306"
volumes:
- "zabbix-db-data:/var/lib/mysql/"


volumes:
zabbix-server-data:
zabbix-db-data:

如果你要使用外部的mysql那么注释掉zabbix-db这段和 zabbix-db-data:这一行

修改environment下的一些参数,直接使用

docker-compose up -d

启动就好

关于数据的备份的话直接备份

/var/lib/docker/volumes/下的所有和zabbix相关的文件即可

欢迎关注Bboysoul的博客www.bboy.app
Have Fun

欢迎关注我的其它发布渠道