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