一、docker-compose安装
# 该环境默认为已安装了Docker
curl -SL https://github.com/docker/compose/releases/download/v2.19.0/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
# 输出版本号则表示成功
docker-compose version
二、创建docker-compose.yml
# 创建存放位置
mkdir -p /data/zabbix && cd /data/zabbix
touch docker-compose.yml
cat > docker-compose.yml << EOF
version: '3'
services:
zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql:centos-5.2-latest
restart: always
environment:
- DB_SERVER_HOST=zabbix-mysql
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix
- MYSQL_ROOT_PASSWORD=123456
- ZBX_SERVER_HOST=zabbix-server-mysql
ports:
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime
- /data/zabbix/fonts/DejaVuSans.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
networks:
- zbx_net
depends_on:
- zabbix-server-mysql
- zabbix-mysql
zabbix-mysql:
image: mysql:8.0.23
restart: always
ports:
- 3306:3306
environment:
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix
- MYSQL_ROOT_PASSWORD=123456
command:
- mysqld
- --default-authentication-plugin=mysql_native_password
- --character-set-server=utf8
- --collation-server=utf8_bin
volumes:
- /etc/localtime:/etc/localtime
- /data/zabbix/db:/var/lib/mysql
networks:
- zbx_net
zabbix-java-gateway:
image: zabbix/zabbix-java-gateway:centos-5.2-latest
restart: always
volumes:
- /etc/localtime:/etc/localtime
networks:
- zbx_net
zabbix-server-mysql:
image: zabbix/zabbix-server-mysql:centos-5.2-latest
restart: always
volumes:
- zabbix-server-vol:/etc/zabbix
- /data/zabbix/alertscripts:/usr/lib/zabbix/alertscripts
- /etc/localtime:/etc/localtime
- /data/zabbix/config:/etc/zabbix/
ports:
- 10051:10051
environment:
- DB_SERVER_HOST=zabbix-mysql
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix
- MYSQL_ROOT_PASSWORD=123456
- ZBX_JAVAGATEWAY=zabbix-java-gateway
- ZBX_JAVAGATEWAY_ENABLE=true
- ZBX_JAVAGATEWAYPORT=10052
depends_on:
- zabbix-mysql
networks:
- zbx_net
zabbix-agent:
image: zabbix/zabbix-agent:centos-5.2-latest
restart: always
ports:
- 10050:10050
environment:
- ZBX_HOSTNAME=Zabbix server
- ZBX_SERVER_HOST=zabbix-server-mysql
- ZBX_SERVER_PORT=10051
networks:
- zbx_net
networks:
zbx_net:
driver: bridge
volumes:
zabbix-server-vol:
EOF
三、本地创建挂载目录
# 在/data/zabbix目录下创建
mkdir alertscripts db fonts
# 下载中文字体防止中文乱码
wget https://dl.cactifans.com/zabbix_docker/msty.ttf
mv msty.ttf DejaVuSans.ttf
四、运行docker-compose
# 在docker-compose.yml文件目录中运行
docker-compose up -d
# 查看容器运行日志
docker-compose logs -f
# 查看容器运行状态
docker-compose up
# 查看容器启动的进程
docker-compose top
标签:compose,yml,zabbix,docker,data,ttf From: https://www.cnblogs.com/ronnybox/p/17524957.html使用浏览器访问登录页面,默认密码为Admin/zabbix