version: '2' services: zabbix-mysql-service: image: daocloud.io/library/mysql:5.7 #容器名 container_name: zabbix-mysql-service environment: - MYSQL_ROOT_PASSWORD=123456 #MYSQL 密码 restart: always #自动启动 #zabbix 服务 zabbix-server-service: image: monitoringartist/zabbix-xxl:3.2.6 links: - zabbix-mysql-service:mysqlhost #容器MYSQL 服务连接,内部进行通信 container_name: zabbix-server-service restart: always depends_on: #依赖于 MYSQL 服务 ! 注意启动顺序 - zabbix-mysql-service ports: - "8888:80" #暴露端口 8888 ---》 80 端口 environment: - ZS_DBHost=mysqlhost #默认的配置文件 - ZS_DBUser=root - ZS_DBPassword=123456 zabbix-agent-a: image: zabbix/zabbix-agent:ubuntu-3.2.6 links: - zabbix-server-service:zabbixserverhost # zabbix-server 服务容器 网络内部通信 container_name: zabbix-agent-a restart: always depends_on: - zabbix-server-service # 依赖于zabbix-server 服务 environment: - ZBX_HOSTNAME=zabbix-agent-service-a - ZBX_SERVER_HOST=zabbixserverhost zabbix-agent-b: image: zabbix/zabbix-agent:ubuntu-3.2.6 links: - zabbix-server-service:zabbixserverhost container_name: zabbix-agent-b restart: always depends_on: - zabbix-server-service |