[TOC]

创建本地数据存储目录

mkdir -p /data/zabbix/db
mkdir /data/zabbix/alertscripts
mkdir /data/zabbix/fonts

下载字体

wget  -O /data/zabbix/fonts/DejaVuSans.ttf https://dl.cactifans.com/zabbix_docker/msty.ttf

创建专用网络

docker network create -d bridge zabbix_net

创建Docker卷

docker volume create zabbix-server-vol

运行 Mysql数据库容器

docker run -itd \
	-p 3306:3306 \
	--name zabbix-mysql \
	--network zabbix_net \
	--restart unless-stopped \
	-v /etc/localtime:/etc/localtime \
	-v /data/zabbix/db:/var/lib/mysql \
	-e MYSQL_DATABASE="zabbix" \
	-e MYSQL_USER="zabbix" \
	-e MYSQL_PASSWORD="zabbix123" \
	-e MYSQL_ROOT_PASSWORD="root123" \
	swr.cn-north-1.myhuaweicloud.com/iivey/mysql:8.0.23  \
	--default-authentication-plugin=mysql_native_password --character-set-server=utf8 \
	--collation-server=utf8_bin

运行 zabbix-java-gateway 容器

docker run -idt \
	-v /etc/localtime:/etc/localtime  \
	--restart=always \
	--name=zabbix-java-gateway \
	--network zabbix_net \
	zabbix/zabbix-java-gateway:latest

运行 zabbix-server-mysql 容器

docker run -dit \
	-p 10051:10051 \
	--mount source=zabbix-server-vol,target=/etc/zabbix \
	-v /etc/localtime:/etc/localtime \
	-v /data/zabbix/alertscripts:/usr/lib/zabbix/alertscripts \
	--name=zabbix-server-mysql \
	--restart=always \
	--network zabbix_net \
	-e DB_SERVER_HOST="zabbix-mysql" \
	-e MYSQL_DATABASE="zabbix" \
	-e MYSQL_USER="zabbix" \
	-e MYSQL_PASSWORD="zabbix123" \
	-e MYSQL_ROOT_PASSWORD="root123" \
	-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
	-e ZBX_JAVAGATEWAY_ENABLE="true" \
	-e ZBX_JAVAGATEWAYPORT=10052 \
	zabbix/zabbix-server-mysql:latest

运行 zabbix-web-nginx-mysql 容器

docker run -dit \
-p 8081:8080 \
-v /etc/localtime:/etc/localtime \
-v /data/zabbix/fonts/DejaVuSans.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf \
--name zabbix-web-nginx-mysql \
--restart=always \
--network zabbix_net \
-e DB_SERVER_HOST="zabbix-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix123" \
-e MYSQL_ROOT_PASSWORD="root123" \
-e ZBX_SERVER_HOST="zabbix-server-mysql"  \
zabbix/zabbix-web-nginx-mysql:latest

运行 zabbix-agent 容器

docker run -dit --name zabbix-agent \
	-p 10050:10050 \
	--network zabbix_net \
	-e ZBX_HOSTNAME="Zabbix server" \
	-e ZBX_SERVER_HOST="zabbix-server-mysql" \
	-e ZBX_SERVER_PORT=10051 \
	zabbix/zabbix-agent:latest