I am trying to get zabbix in docker, I created a docker-compose with several services, one of them is the database. I need to raise the database first and then get the ip of the database and set the environment variable for other services, however I do not know how to do it, I already tried to use the links, but I'm not having success.
This is my docker-compose.yml
version: "2"
services:
mysql-zabbix :
image: "mysql:5.7"
ports:
- "53306:3306"
networks:
- net_zabbix
volumes:
- "vol_db_zabbix:/var/lib/mysql"
environment:
- "MYSQL_ROOT_PASSWORD=abcd"
- "MYSQL_DATABASE=zabbix"
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
zabbix-server:
image: "zabbix/zabbix-server-mysql:alpine-3.4.11"
ports:
- "10051:10051"
networks:
- net_zabbix
environment:
- "DB_SERVER_PORT=53306"
- DB_SERVER_HOST=zabbix.db
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
depends_on:
- mysql-zabbix
external_links:
- mysql-zabbix:zabbix.db
zabbix-web:
image: "zabbix/zabbix-web-apache-mysql:alpine-3.4.11"
ports:
- "80:80"
networks:
- net_zabbix
environment:
- DB_SERVER_HOST=zabbix.db
- "DB_SERVER_PORT=53306"
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
- ZBX_SERVER_HOST=zabbix.server
- "PHP_TZ=America/Sao_Paulo"
depends_on:
- zabbix-server
external_links:
- mysql-zabbix:zabbix.db
- zabbix-server:zabbix.server
zabbix-agent:
image: "zabbix/zabbix-agent:alpine-3.4.11"
ports:
- "10050:10050"
networks:
- net_zabbix
environment:
- "ZBX_HOSTNAME=demo_zabbix"
- ZBX_SERVER_HOST=zabbix.server
external_links:
- zabbix-server:zabbix.server
zabbix-proxy:
image: "zabbix/zabbix-proxy-sqlite3:alpine-3.4.11"
ports:
- "10053:10050"
networks:
- net_zabbix
environment:
- "ZBX_HOSTNAME=demo_zabbix"
- ZBX_SERVER_HOST=zabbix.server
external_links:
- zabbix-server:zabbix.server
networks:
net_zabbix:
volumes:
vol_db_zabbix: