Cant change hostname of LB Agent container

  • I have one stack (zookeeper) that has a 3 container Zookeeper service.

  • I have a second stack (vms) that has a LoadBalancer in it that is linked to the zookeeper stack and service.

  • I want to change the hostname of the LB Agent container so that other services in the vms stack can find the loadbalancer by host name. So i used the ‘o.rancher.container.hostname_override : container_name’ label with the LB Agent but it seems to be ignored and the LB AGent container still gets a random hostname.

  • Docker-compose is below.

NB I am using the latest rancher version and docker 1.9 on centos 7 hosts

zookeeper:
  restart: always
  external_links:
  - zookeeper/zookeeper:zookeeper
  expose:
  - 2181:2181/tcp
  tty: true
  image: rancher/load-balancer-service
  stdin_open: true
  labels:
    io.rancher.container.hostname_override : container_name
metad:
  restart: always
  links:
  - zookeeper
  tty: true
  image: centos
  stdin_open: true
  labels:
    io.rancher.container.hostname_override : container_name
kafka-conf:
  image: containers.cisco.com/gemenysm/kafka-config:2.1.0
  volumes_from:
    - kafka
  net: "container:kafka"
kafka:
  image: containers.cisco.com/gemenysm/kafka:2.1.0-x
  links:
  - zookeeper
  environment:
    KAFKA_ZOOKEEPER_CONNECT: "zookeeper"
  labels:
    io.rancher.sidekicks: kafka-conf
    io.rancher.container.network: true
  volumes:
    - /opt/rancher

Currently, the io.rancher.container.hostname_override : container_name is not respected in the load balancer service.

We are in the middle of refactoring the load balancer service based on user feedback.

I’m thinking that this enhancement would help your use case?

https://github.com/rancher/rancher/issues/679

I think there’s some confusion here… hostname_override would change the hostname inside the container if it worked, but nothing running inside the balancer container cares about the hostname. The label does not affect what is put into DNS for any other container to find.

To change that you would rename the service, or link to the service with an “as name” alias. But you seem to want the name to be zookeeper anyway since that’s what’s in the environment variable. It sounds like maybe your problem is if you try to resolve the name very quickly the dns config isn’t in yet and it fails (#2341)?