docker compose一键部署zabbix 7.0 LTS实战

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.编写docker-compose文件

# 声明docker-compose的版本,未来该参数会被移除!
version: '3.8'

# 定义各个服务类型
services:
   # 我们可以自定义服务的名称,最好见名之意
   mysql-server:
     # 指定镜像的地址
     image: mysql:8.0.36-oracle
     # 指定容器的名称
     container_name: mysql-server
     # 指定重启策略
     restart: unless-stopped
     # 指定环境变量
     environment:
       MYSQL_ROOT_PASSWORD: "123456"
       MYSQL_DATABASE: zabbix
       MYSQL_USER: linux94
       MYSQL_PASSWORD: oldboyedu
     # 加入自定义网络
     networks:
       - zabbix-net
     # 启动是传参
     command: ["--character-set-server=utf8", "--collation-server=utf8_bin", "--default-authentication-plugin=mysql_native_password"]
     
   zabbix-java-gateway:
     container_name: zabbix-java-gateway
     image: zabbix/zabbix-java-gateway:alpine-7.0-latest
     restart: unless-stopped
     networks:
       - zabbix-net
     
   zabbix-server:
     container_name: zabbix-server-mysql
     # 依赖哪个服务
     depends_on:
       - mysql-server
     image: zabbix/zabbix-server-mysql:alpine-7.0-latest
     restart: unless-stopped
     environment:
       DB_SERVER_HOST: mysql-server
       MYSQL_DATABASE: zabbix
       MYSQL_USER: linux94
       MYSQL_PASSWORD: oldboyedu
       MYSQL_ROOT_PASSWORD: "123456"
       ZBX_JAVAGATEWAY: zabbix-java-gateway
     networks:
       - zabbix-net
     # 指定端口映射
     ports:
       - "10051:10051"
       
   zabbix-web-nginx-mysql:
     container_name: zabbix-web-nginx-mysql
     depends_on:
       - zabbix-server
     image: zabbix/zabbix-web-nginx-mysql:alpine-7.0-latest
     ports:
       - "80:8080"
     restart: unless-stopped
     environment:
       DB_SERVER_HOST: mysql-server
       MYSQL_DATABASE: zabbix
       MYSQL_USER: linux94
       MYSQL_PASSWORD: oldboyedu
       MYSQL_ROOT_PASSWORD: "123456"
     networks:
       - zabbix-net

# 定义网络深圳
networks:
  # 定义网络的名称,可以自定义,此处定义上面的服务可以引用。
  zabbix-net:
     name: yinzhengjie-zabbix
     ipam:
       driver: default
       config:
         - subnet: 172.20.100.0/16
           gateway: 172.20.100.254

二.启动实例

docker-compose up -d
posted @ 2024-10-23 23:46  尹正杰  阅读(38)  评论(0编辑  收藏  举报