1

I have a problem when trying to resolve MX records using Resolv::DNS. When I execute the following lines directly on my Mac in irb, everything works:

> require "resolv"
> Resolv::DNS.new.getresource("stackoverflow.com", Resolv::DNS::Resource::IN::MX)
=> #<Resolv::DNS::Resource::IN::MX:0x00007fba42812ff0 @preference=10, @exchange=#<Resolv::DNS::Name: alt4.aspmx.l.google.com.>, @ttl=243>

The same line executed inside a docker container returns an error:

> require "resolv"
> Resolv::DNS.new.getresource("stackoverflow.com", Resolv::DNS::Resource::IN::MX)
Resolv::ResolvError: DNS result has no information for stackoverflow.com
from /usr/local/lib/ruby/2.4.0/resolv.rb:492:in `getresource'

I think the problem is docker-machine. I'm running docker-machine configured by dinghy 4.6.3 (see https://github.com/codekitchen/dinghy) with the following configuration:

Boot2Docker version 18.01.0-ce, build HEAD : 0bb7bbd - Thu Jan 11 16:32:39 UTC 2018
Docker version 18.01.0-ce, build 03596f5

docker@dinghy:~$ busybox | head -1
BusyBox v1.27.2 (2017-10-30 14:58:40 UTC) multi-call binary.

And my docker container is based on ruby:2.4.3-stretch.

I'm not sure if it is simple an issue with the resolv.conf

docker@dinghy:~$ cat /etc/resolv.conf 
nameserver 10.0.2.3

Is the config enough for mx lookups?

Update:

This is the dig response from within a container (not from the docker-machine itself, unfortunately the dig package doesn't ship with busybox):

root@3ef2090b7864:/usr/src/app# dig @10.0.2.3 MX stackoverflow.com

; <<>> DiG 9.10.3-P4-Debian <<>> @10.0.2.3 MX stackoverflow.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOTIMP, id: 32375
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;stackoverflow.com.     IN  MX

;; Query time: 0 msec
;; SERVER: 10.0.2.3#53(10.0.2.3)
;; WHEN: Tue Apr 03 14:29:30 CEST 2018
;; MSG SIZE  rcvd: 46
23tux
  • 14,104
  • 15
  • 88
  • 187
  • `docker@dinghy:~$ dig @10.0.2.3 MX stackoverflow.com` ? – Pavel Mikhailyuk Apr 03 '18 at 11:05
  • `docker@dinghy:~$ dig @10.0.2.3 MX stackoverflow.com -sh: dig: not found` unfortunately, the package doesn't ship with busybox, and `nslookup` doesn't implement the `-q` option – 23tux Apr 03 '18 at 12:23
  • But it is available in my container (I've updated my answer, the code is bad formatted here in the comments) – 23tux Apr 03 '18 at 12:30
  • Please run `dig @1.1.1.1 MX stackoverflow.com` (or "@ 8.8.8.8") and watch the difference. Conclusion: DNS at 10.0.2.3 works wrong – Pavel Mikhailyuk Apr 03 '18 at 12:36
  • So, Ruby is fine: it does request to 10.0.2.3 and get nothing about stackoverflow.com MX records. – Pavel Mikhailyuk Apr 03 '18 at 12:37
  • ah ok, it looks like my docker dns is configured wrong. Any idea how to solve this? Just using 8.8.8.8 doesn't seem to help. – 23tux Apr 03 '18 at 12:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/168126/discussion-between-pavel-mikhailyuk-and-23tux). – Pavel Mikhailyuk Apr 03 '18 at 13:56

0 Answers0