Regarding linking containers I’m baffled about how I’m supposed to use the environment variables inserted into the container. Taking the example given in the docker links page ( Legacy container links | Docker Docs ) it states
$ sudo docker run --rm --name web2 --link db:db training/webapp env
. . .
DB_NAME=/web2/db
DB_PORT=tcp://172.17.0.5:5432
DB_PORT_5432_TCP=tcp://172.17.0.5:5432
DB_PORT_5432_TCP_PROTO=tcp
DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_ADDR=172.17.0.5
and then goes on to say
You can see that Docker has created a series of environment variables with useful information about the source db container.
What’s puzzling me is how I’m supposed to use the entry, say “DB_PORT_5432_TCP_PORT=5432” to discover that the DB is listening on port 5432. Given that I need to know the port number 5432 to create the ENV variable name ‘DB_PORT_5432_TCP_PORT’ to discover the value 5432 I don’t see how it’s very useful.
Similarly I’m not certain how I’m supposed to use the DB_NAME entry. Perhaps it’s useful as a key for etcd ?
I’m fully prepared to believe my knowledge is lacking, and that I’m missing something obvious - but I’m genuinely unsure what the developers intended