获取镜像

  1. # 查看可用的稳定版本
  2. sudo docker search zabbix
  3. sudo docker pull daocloud.io/library/mysql:8
  4. sudo docker pull monitoringartist/zabbix-xxl
  5. sudo docker image ls |grep zabbix

服务编排

  1. mkdir -p /share/zabbix
  2. vi /share/zabbix/docker-compose.yml

服务编排内容如下:

  1. version: '2'
  2. services:
  3. zabbix-mysql:
  4. image: daocloud.io/library/mysql:8
  5. container_name: zabbix-mysql
  6. environment:
  7. - MYSQL_ROOT_PASSWORD=123456
  8. restart: always
  9. zabbix-server:
  10. image: monitoringartist/zabbix-xxl
  11. links:
  12. - zabbix-mysql:mysqlhost
  13. container_name: zabbix-server
  14. restart: always
  15. depends_on:
  16. - zabbix-mysql
  17. ports:
  18. - "8888:80"
  19. environment:
  20. - ZS_DBHost=mysqlhost
  21. - ZS_DBUser=root
  22. - ZS_DBPassword=123456

服务构建

cd /share/zabbix
sudo docker-compose -f docker-compose.yml build --no-cache # 不带缓存构建(只创建镜像,不会启动容器)
sudo docker-compose -f docker-compose.yml up -d  # 构建后运行
sudo docker-compose -f docker-compose.yml up --build # 跟踪方式构建,可用于调试
sudo docker-compose -f docker-compose.yml stop # 停止
sudo docker-compose -f docker-compose.yml down # 移除

验证

cd /share/zabbix
# 查看进程
sudo docker-compose -f docker-compose.yml ps
# 进入终端
sudo docker exec -it zabbix-server /bin/bash
# 查看日志
sudo docker logs zabbix-server
sudo docker logs -f -t --tail=50 zabbix-server
# 查看网络
sudo docker network ls
sudo docker inspect zabbix-server