create mysql dir
mkdir -p /home/docker/mysql
mkdir -p /home/docker/zabbix
docker file
vi zabbix/docker-compose.yml
version: '3.7'
services:
mysql-server:
image: mysql:8.0-oracle
container_name: mysql-8.0
command:
- mysqld
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_bin
- --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_USER: zabbix
MYSQL_PASSWORD: zabbix
MYSQL_DATABASE: zabbix
volumes:
- "/etc/localtime:/etc/localtime"
- "/home/data/docker/mysql:/var/lib/mysql"
ports:
- "33306:3306"
networks:
- zbx_net
zabbix-server:
image: zabbix/zabbix-server-mysql:ubuntu-6.2-latest
container_name: zabbix-server-6.2
environment:
DB_SERVER_HOST: mysql-server
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: zabbix
ports:
- "30051:10051"
depends_on:
- "mysql-server"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- "/home/data/docker/zabbix:/var/lib/zabbix"
networks:
- zbx_net
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:ubuntu-6.2-latest
container_name: zabbix-web-6.2
environment:
DB_SERVER_HOST: mysql-server
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: zabbix
PHP_TZ: Asia/Shanghai
ZBX_SERVER_HOST: zabbix-server
ports:
- 38080:8080
depends_on:
- mysql-server
- zabbix-server
networks:
- zbx_net
zabbix-agent:
image: zabbix/zabbix-agent:ubuntu-6.2-latest
container_name: zabbix-agent-6.2
environment:
ZBX_SERVER_HOST: zabbix-server
ports:
- "30050:10050"
depends_on:
- "zabbix-server"
networks:
- zbx_net
networks:
zbx_net:
build/re-build and run
cd zabbix && docker compose up -d && cd ..
open
http://localhost:80
amdin/zabbix
stop and delete container
cd zabbix && docker compose down && cd ..