获取镜像
# 查看可用的稳定版本
sudo docker search zabbix
sudo docker pull daocloud.io/library/mysql:8
sudo docker pull monitoringartist/zabbix-xxl
sudo docker image ls |grep zabbix
服务编排
mkdir -p /share/zabbix
vi /share/zabbix/docker-compose.yml
服务编排内容如下:
version: '2'
services:
zabbix-mysql:
image: daocloud.io/library/mysql:8
container_name: zabbix-mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
restart: always
zabbix-server:
image: monitoringartist/zabbix-xxl
links:
- zabbix-mysql:mysqlhost
container_name: zabbix-server
restart: always
depends_on:
- zabbix-mysql
ports:
- "8888:80"
environment:
- ZS_DBHost=mysqlhost
- ZS_DBUser=root
- 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