Can I edit /etc/hosts?

(Gergely Fazekas) #1

I think I figured out what the problem is on my installation - I adjusted the server’s /etc/hosts file, so the smtp server resolves to the internal IP instead of the public one, however that goes to hell because the same setting isn’t in the container’s /etc/hosts file.

How can I echo the setting while bootstrapping? Because if I ssh into the container, obviously /etc/hosts is on a read-only filesystem.

(Jonathan Feist) #2

Try (stab in the dark here) adding something like echo '' >> /etc/hosts to line 63 by sudo nano -c +63 /var/docker/containers/app.yml replacing:

- exec: echo "Beginning of custom commands" with
- exec: echo "echo '' >> /etc/hosts"

(Gergely Fazekas) #3

Thanks for the suggestion!

Unfortunately that didn’t do the trick. And I’m almost 100% sure this would solve my email troubles.

(Kane York) #4

Er, remove the first echo. And have correct YAML syntax.

- exec: "echo '' >> /etc/hosts"

(Gergely Fazekas) #5

(): did not find expected key while parsing a block mapping at line 9 column 1
YAML syntax error. Please check your configuration files.

If I have the first echo as per @def’s suggestion, bootstrapping goes through (without effect though)

(Gergely Fazekas) #6

I managed to edit the file, buy switching to root with sudo su and editing /var/lib/docker/containers/CONTAINER-ID/hosts

It’s a pretty ugly hack, and not persistent, but at least fixes the problem I’ve been having.

(Sam Saffron) #7

We now have runit which does a custom init process, you would hook changes to hosts or resolve and any other protected files there.

(Avinash Singh) #8

You cannot edit /etc/hosts file but you can copy it somewhere else and then make changes in
LD_LIBRARY_PATH and point that hosts file which you copied and then edit it.Please refer to the following link

(Gergely Fazekas) #9

Thanks! This is useful, as I’m deploying Discourse on GreenQloud VMs and our network setup messes a bit with the internal/public IPs