I want my Discourse installation to use my local nameserver. (So that it resolves the hostnames of the other computers in the same data center to their LAN addresses instead of the external IP.) The /etc/resolv.conf
file in the container does include that nameserver, but it puts Google’s nameservers first. Is there any way to customize the content of resolv.conf
?
As far as I’m aware, the container’s resolv.conf
is copied from the host. So, if the container host has Google’s nameservers, then that’s what the container will get. AFAIK, there’s no way for a container image, nor the command line, to override that behaviour. Of course, you can edit the container’s resolv.conf
after it is started, but there’s nothing in the Discourse images to do that that I can find. Certainly, the discourse.org hosting, which uses the same images as are publically available, don’t override resolv.conf
(it definitely gets copied in from the host).
Well, here is the host’s resolv.conf:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.33.55.1
And here is the one from the container:
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 10.33.55.1
More strangeness:
I rebuilt the Discourse container, and edited resolv.conf
to be just nameserver 10.33.55.1
, and I could immediately resolve hostnames correctly. But whenever I restart the container, the contents of resolv.conf
changes to:
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 10.33.55.1
So something is running when the container starts, and adding the Google nameservers to resolv.conf
. Or does the container filesystem revert to its previous state whenever it is restarted?
I found the documentation on how Docker creates and maintains /etc/resolv.conf
: Redirecting…
It doesn’t seem to be doing exactly what it says there, but it told me enough to fix the problem. I added the following line to my container’s YAML file:
docker_args: --dns=10.33.55.1
And now I get the resolv.conf
file I need.
This topic was automatically closed after 3034 days. New replies are no longer allowed.