-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
The env var names seem to be more complicated than they need to be (and certainly wouldn't be named this way outside of Docker).
I understand the need to have the var names as they are, since linked in stuff can have multiple ports, multiple links in, etc. But I think it could be simplified.
Let's take an example where we've linked in a postgres DB into an app container aliased as "db". This gives us:
DB_PORT_5432_TCP_ADDR=x.x.x.x
DB_PORT=tcp://x.x.x.x:5432
DB_PORT_5432_TCP=tcp://x.x.x.x:5432
DB_NAME=/postgres/db
DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_PROTO=tcp
Unless I'm mistaken, the DB link alias can only be used by one link. So with that we should be able to shorten "DB_PORT_5432_TCP_ADDR" to simple "DB_HOST", since this will only ever be 1 IP address regardless of the ports being exposed.
In all cases you need the know the protocol and the port before being able to access any of the vars.
With regard to DB_PORT, when multiple ports are used this still only ever shows one port.
Perhaps a DB_PORT_0, DB_PORT_1, ... DB_PORT_N for discovering all this information. Also, perhaps this should be renamed to DB_URL instead of DB_PORT.
Or perhaps this all goes away with links version 2 anyway?