Configuring Container DNS

I have some doubts about dnsdomainname command in docker container when I developed non-root DataStage, in Engine Conductor tier.

References to Configure container DNS

How can Docker supply each container a hostname and DNS configuration without having to build a custom image with the hostname written inside? The trick is to overlay three crucial /etc files inside the container with virtual files where it can write fresh information.

In container, run:

1
2
3
4
5
# mount | grep etc

/dev/mapper/rhel-root on /etc/resolv.conf type xfs (rw,relatime,attr2,inode64,noquota)
/dev/mapper/rhel-root on /etc/hostname type xfs (rw,relatime,attr2,inode64,noquota)
/dev/mapper/rhel-root on /etc/hosts type xfs (rw,relatime,attr2,inode64,noquota)

Four different options affect container domain name services, please see official documentation for explanation:

  • -h HOSTNAME or --hostname=HOSTNAME
  • --link=CONTAINER_NAME or ID:ALIAS
  • --dns=IP_ADDRESS
  • --dns-search=DOMAIN
  • --dns-opt=OPTION

So what should dnsdomainname return exactly? for non-root engine docker container, the hostname is is-en-conductor-0.en-cond, but why sometimes dnsdomainname return empty but sometimes return en.cond.

I find the return depends on /etc/hosts file first non-self-loop IP hostname pair, for example:

1
9.30.223.186    is-en-conductor-0.en-cond is-servicesdocker is-xmetadocker

the dnsdomainname will return en-cond, but if change to

1
9.30.223.186    is-xmetadocker is-en-conductor-0.en-cond is-servicesdocker

the command returns empty, and if you run hostname -f (long host name), it returns is-xmetadocker.

0%