moby: when using docker + linking + golang it doesn't read /etc/hosts properly

I have a golang app running in docker with an ubuntu (also tried alpine) image. The /etc/hosts gets changed to (when I link with --link rethink:rethinkdb:

172.17.0.3  2ed4023bd0c4
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2  rethinkdb aeb6c5b5836b rethink

which gorethink can’t resolve, it can however resolve localhost but when I move the line up by the localhost line like so:

172.17.0.3  2ed4023bd0c4
127.0.0.1   localhost
172.17.0.2  rethinkdb aeb6c5b5836b rethink
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

it does work.

I also tried to force Go to use /etc/hosts first instead of DNS and it still failed using the flag GODEBUG=netdns=cgo+1 this had no affect because of the way golang is reading the /etc/hosts file it gives up once it gets to the IPv6 stuff I assume?

Thank you for your help.

@dancannon

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

@daxorid also, looks like you’re running a build of Docker that’s modified by Red Hat; some of those changes result in Docker working different from the official version. If you want to install the official builds, you can install from our apt/yum repository, following the instructions in our documentation https://docs.docker.com/engine/installation/linux/fedora/. That should also give you an up-to-date version (1.10.3 currently, but 1.11 soon)

Was this bug ever resolved? We ran into this bug today and really need a solution.