网上看到一堆使用docker-compose 运行zabbix ,都不台好用,或者因为版本问题,以下是一个整理的
docker-compose ,可以参考
docker-compose
version: "3"
services:
mysql-server:
image: mysql:5.7.16
container_name: mysql-server
command: --character-set-server=utf8 --interactive_timeout=120 --wait_timeout=120 --log_warnings=1 --collation-server=utf8_bin --sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION --lower_case_table_names=1
restart: always
environment:
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix
- MYSQL_ROOT_PASSWORD=zabbix
ports:
- 3306:3306
volumes:
- /data/mysql:/var/lib/mysql
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
zabbix-server-mysql:
image: zabbix/zabbix-server-mysql:5.0.0
container_name: zabbix-server-mysql
ulimits:
nproc: 65535
nofile:
soft: 20000
hard: 40000
privileged: true
cap_add:
- ALL
restart: always
environment:
- DB_SERVER_HOST=mysql-server
- MYSQL_USER=zabbix
- ZBX_CACHESIZE=4096M
- MYSQL_PASSWORD=zabbix
- MYSQL_DATABASE=zabbix
- MYSQL_ROOT_PASSWORD=zabbix
ports:
- 10051:10051
sysctls:
- net.ipv4.ip_local_port_range=1024 65000
- net.ipv4.conf.all.accept_redirects=0
- net.ipv4.conf.all.secure_redirects=0
- net.ipv4.conf.all.send_redirects=0
links:
- mysql-server:mysql
depends_on:
- mysql-server
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- zabbix-server-conf:/etc/zabbix
- zabbix-server-alertscripts:/usr/lib/zabbix/alertscripts
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:5.0.0
environment:
- DB_SERVER_HOST=mysql-server
- MYSQL_USER=zabbix
- PHP_TZ=Asia/Shanghai
- MYSQL_PASSWORD=zabbix
- MYSQL_DATABASE=zabbix
- MYSQL_ROOT_PASSWORD=zabbix
restart: always
ports:
- 80:8080
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
links:
- mysql-server:mysql
- zabbix-server-mysql:zabbix-server
depends_on:
- mysql-server
- zabbix-server-mysql
zabbix-agent:
image: zabbix/zabbix-agent
privileged: true
restart: always
cap_add:
- ALL
volumes:
- /etc/timezone:/etc/timezone
environment:
ZBX_SERVER_HOST: zabbix-server-mysql
ports:
- '10050:10050'
volumes:
zabbix-server-conf:
zabbix-server-alertscripts:
启动
docker-compose up -d
效果
说明
对于docker运行相关的问题还是应该多看看dockerfile 的内容,可以方便的排查问题,网上的内容不可都信, 看下dockerfile好多问题就清晰明了了