Cannot get links alias to work

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?

Hi,

I’ve got the same scenario with a quite similar stack ! When using alias name, it uses /etc/resolv.conf “search” entry to complete short names for “ping” command. however, on the same container, if you install dnsutils and try to run a dig command with the same alias name, the dig will return the rancher ip address and confirm that the DNS server answering the request was rancher server.

Can you please test the dig command and give us your result ?

thanks.