桥接模式(mysql和zabbix-server镜像本人修改了一些配置进行重构过)
cat zabbix.yml version: '3' services: mysql: image: debian-mysql5.7:latest environment: MYSQL_USER: zabbix MYSQL_DATABASE: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 volumes: - /data/mysql/zabbix:/var/lib/mysql ports: - 23307:3306 restart: always networks: - zabbix zabbix-java-gateway: image: zabbix-java-gateway:latest ports: - 20052:10052 restart: always networks: - zabbix zabbix-server: image: zabbix-server:0.1 environment: ZBX_CACHESIZE: 256M ZBX_HISTORYCACHESIZE: 64M ZBX_HISTORYINDEXCACHESIZE: 10M ZBX_STARTPOLLERS: 30 ZBX_STARTPOLLERSUNREACHABLE: 20 ZBX_STARTDISCOVERERS: 8 ZBX_STARTHTTPPOLLERS: 5 ZBX_STARTTRAPPERS: 20 ZBX_STARTPINGERS: 10 ZBX_STARTDBSYNCERS: 4 ZBX_JAVAGATEWAY: zabbix-java-gateway ZBX_JAVAGATEWAY_ENABLE: "true" DB_SERVER_HOST: mysql MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 WECHAT_PARTYID: 1 WECHAT_APPID: 1000003 WECHAT_CROPID: xxxxxxxxxxxxxxxxxx WECHAT_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx links: - mysql ports: - 20051:10051 depends_on: - mysql restart: always networks: - zabbix zabbix-web: image: zabbix-web:latest environment: PHP_TZ: Asia/Shanghai DB_SERVER_HOST: mysql MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 links: - mysql ports: - 127.0.0.1:20081:80 depends_on: - zabbix-server - mysql restart: always networks: - zabbix networks: zabbix: driver: bridge
主机模式
[root@localhost docker-compose]# cat zabbix.yml_bak version: '3' services: mysql: image: debian-mysql5.7:latest environment: MYSQL_USER: zabbix MYSQL_DATABASE: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 volumes: - /data/mysql/zabbix:/var/lib/mysql restart: always network_mode: host zabbix-java-gateway: image: zabbix-java-gateway:latest restart: always network_mode: host zabbix-server: image: zabbix-server:0.1 environment: DB_SERVER_HOST: 127.0.0.1 ZBX_JAVAGATEWAY: 127.0.0.1 ZBX_JAVAGATEWAY_ENABLE: "true" MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 WECHAT_PARTYID: 1 WECHAT_APPID: 1000003 WECHAT_CROPID: xxxxxxxxxxxxxxx WECHAT_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx restart: always network_mode: host zabbix-web: image: zabbix-web:latest extra_hosts: - "zabbix-server:127.0.0.1" environment: PHP_TZ: Asia/Shanghai DB_SERVER_HOST: 127.0.0.1 MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: zabbixDB@2019 restart: always network_mode: host