Seriously, the current state of connecting docker hosts together is poor. Most solutions seem to rely on stuffing ENVIRONMENT variables into docker hosts. I think we can do better..
I want to create a config file that looks like this:
# Host is a reserved name, MyWebContainer will look for a docker container called MyWebContainer
HOST:(*)80 --> MyWebContainer:8080
# any tcp connections on (*) any source port, with the dst port as 3306 will be routed to the mydatabase continer port 3306
MyWebContainer(*)3306 --> MyDataBase:3306
MyWebContainer(*)6379 --> redis1(6379), redis2(6379), redis3(6379)
Note: I understand that this replaces DNS (destination host) with destination port, but i think this is acceptable. If you have 2 components that use the same port, such as 2 back end servers both on port 8080, then you'd simply need to run one of them such that the exposed port is different. i.e. docker run -p 8888:8080 myOtherService
The advantage to this solution is that it removes a whole class of configuration (the db_host, redis_host etc) out from with-in the docker container, and into the run-time.