创建Docker Compose文件: 首先,你需要创建一个docker-compose.yml
文件来定义Zabbix所需的服务。
version: '3'
services:
zabbix-server:
image: zabbix/zabbix-server-mysql:latest
environment:
DB_SERVER_HOST: "mysql-server"
MYSQL_DATABASE: "zabbix"
MYSQL_USER: "zabbix"
MYSQL_PASSWORD: "your_password"
ports:
- "10051:10051"
depends_on:
- mysql-server
mysql-server:
image: mysql:5.7
environment:
MYSQL_DATABASE: "zabbix"
MYSQL_USER: "zabbix"
MYSQL_PASSWORD: "your_password"
MYSQL_ROOT_PASSWORD: "root_password"
volumes:
- zabbix-mysql:/var/lib/mysql
zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql:latest
environment:
DB_SERVER_HOST: "mysql-server"
MYSQL_DATABASE: "zabbix"
MYSQL_USER: "zabbix"
MYSQL_PASSWORD: "your_password"
ZBX_SERVER_HOST: "zabbix-server"
ports:
- "80:8080"
depends_on:
- mysql-server
- zabbix-server
volumes:
zabbix-mysql:
这个docker-compose.yml
文件定义了三个服务:Zabbix服务器、MySQL数据库和Zabbix前端(使用Nginx)。
启动服务: 在包含此docker-compose.yml
文件的目录中运行以下命令:
docker-compose up -d
这将会下载必要的Docker镜像,并启动Zabbix服务。
方法二:
用BT宝塔的数据库,新建一个zabbixdocker
?docker-compose.yml
version: '3'
services:
zabbix-server:
image: zabbix/zabbix-server-mysql:latest
environment:
DB_SERVER_HOST: "192.177.254.115"
MYSQL_DATABASE: "zabbixdocker"
MYSQL_USER: "zabbixdocker"
MYSQL_PASSWORD: "123456"
ports:
- "10051:10051"
zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql:latest
environment:
DB_SERVER_HOST: "192.177.254.115"
MYSQL_DATABASE: "zabbixdocker"
MYSQL_USER: "zabbixdocker"
MYSQL_PASSWORD: "123456"
ZBX_SERVER_HOST: "zabbix-server"
ports:
- "8081:8080"
depends_on:
- zabbix-server