I have a docker-compose.yml file with 3 containers:
- zabbix-server - a web application
- zabbix-db - database
- zabbix-db-storage - database storage volume
zabbix-sever has a link to zabbix-db
with alias zabbix.db
:
zabbix-server:
links:
- zabbix-db:zabbix.db
environment:
- ZS_DBHost=zabbix.db
See file details here: https://gist.github.com/geirgp/8982358d618d638cb98c20fed6581008
When i run this locally by executing docker-compose up -d
it works just fine. I can verify the link as follows:
$ docker exec -it zabbix_zabbix-server_1 /bin/bash
[root@e2de3f58855c /]# ping zabbix.db
PING zabbix.db (172.17.0.5) 56(84) bytes of data.
64 bytes from zabbix-db_1 (172.17.0.5): icmp_seq=1 ttl=64 time=0.181 ms
64 bytes from zabbix-db_1 (172.17.0.5): icmp_seq=2 ttl=64 time=0.076 ms
However, if I try to deploy it to rancher ( rancher-compose up
) the zabbix.db
alias does not seem to have a record in the internal rancher dns server:
$ docker exec -it r-zabbix_zabbix-server_1 /bin/bash
[root@3cebb6985b1e /]# ping zabbix.db
ping: unknown host zabbix.db
Pinging zabbix-db
(service name) directly works, so I guess the link is there in a way:
[root@3cebb6985b1e /]# ping zabbix-db
PING zabbix-db.zabbix-server.zabbix.rancher.internal (10.42.132.243) 56(84) bytes of data.
64 bytes from 10.42.132.243: icmp_seq=1 ttl=64 time=0.192 ms
64 bytes from 10.42.132.243: icmp_seq=2 ttl=64 time=0.077 ms
How can I get the links alias to work?