Hacker News new | past | comments | ask | show | jobs | submit login

Q: Why do you want to change /etc/hosts and /etc/resolv.conf (besides hacking DNS for testing purposes)?



some of us use HOSTS to write config

e.g.

    10.0.12.34 mysql_host
This allows some degree of flexbility

1. boot up new instances quickly as long as HOSTS is correct

2. Don't have to hard-code actual mysql server IPs.

3. Make mysql master/slave failover much easier.


I think most folks doing devops end up using things more like zookeeper, consul, etc. instead to perform the above as opposed to hosts.


Remember you may have to deploy third-party processes as well as apps whose code you control. Most existing software uses OS-standard APIs for doing things like resolving hosts, and you can't just point it at a path in zk. That means running a DNS server or configuring /etc/hosts.


tiny/small sites don't require heavy lifters like zookeeper, however they do require some degree of clustering and sometimes migrating.


Regarding number two, you'll just link your containers together with docker. See https://docs.docker.com/userguide/dockerlinks/

It seems that most issues OP have is mostly because misunderstanding or lack of knowledge.


Umm, so, how do you deal with Docker when you have more than one physical machine? It seems half the stuff it does just doesn't work then, and you have to pile on further abstractions anyway, using Docker just as a simple container management system (of which we have working ones already) and container build system (of which there are far better systems available).


What if the mysql server isn't in a docker container or even on the same machine?


Then you should be (ideally) using a service discovery solution or (less ideally) wiring up with environment variables. This is (one reason) why CoreOS uses etcd.


then just use environment variables (ENV keyword in Dockerfile or --env param in docker run command)


The problem with ENV is that you can't change server IP on the fly, you have to restart the web server to apply new ENV


To run unit tests which rely on certain hosts to resolve to 127.0.0.1.


> To run unit tests which rely on certain hosts to resolve to 127.0.0.1.

If you are unit testing DNS infrastructure, shouldn't you mock DNS things?


I'm not unit testing DNS infrastructure. I'm unit testing an Apache module. I send requests to different virtual hosts on 127.0.0.1:80, and checking whether the responses are what I expect.


That sounds sorta like an integration test; a unit test wouldn't talk to DNS.


Because its used by the applications Id like to contain fully, you know, for all the purposes containers are supposed to be awesome?

In this scenario I dont control the dns server and the app reeally likes aliases instead of IPs.


you know. On the project I'm working on, I thought about using the hosts file as a method of configuring the behaviour of a server. "mycomp-eventserver xxx.xxx.xxx.xxx"

In the end, we just created configuration files for it, as more often then not, there are other factors that need to be included.

That said, maybe these requirements are being set by applications that are not yours to mess around with.

In which case, may god have mercy on your soul.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: