4 ms·
Q: Why do you want to change /etc/hosts and /etc/resolv.conf (besides hacking DNS for testing purposes)?
by dz0ny 12y ago
Q: Why do you want to change /etc/hosts and /etc/resolv.conf (besides hacking DNS for testing purposes)?
- est 12y agosome 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.
- ironchef 12y agoI think most folks doing devops end up using things more like zookeeper, consul, etc. instead to perform the above as opposed to hosts.
- est 12y agotiny/small sites don't require heavy lifters like zookeeper, however they do require some degree of clustering and sometimes migrating.
- ajdecon 12y agoRemember 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.
- diggan 12y agoRegarding number two, you'll just link your containers together with docker. See https://docs.docker.com/userguide/dockerlinks/ https://docs.docker.com/userguide/dockerlinks/ It seems that most issues OP have is mostly because misunderstanding or lack of knowledge.
- Zikes 12y agoWhat if the mysql server isn't in a docker container or even on the same machine?
- sevos1987 12y agothen just use environment variables (ENV keyword in Dockerfile or --env param in docker run command)
- est 12y agoThe 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
- eropple 12y agoThen 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.
- vertex-four 12y agoUmm, 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).
- FooBarWidget 12y agoTo run unit tests which rely on certain hosts to resolve to 127.0.0.1.
- kanzure 12y ago> 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?
- FooBarWidget 12y agoI'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.
- lowmagnet 12y agoThat sounds sorta like an integration test; a unit test wouldn't talk to DNS.
- antocv 12y agoBecause 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.
- GhotiFish 12y agoyou 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.