-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables need to be better #37
Comments
As a start, we needn't include the project name in the link name. So without us adding any additional variables, this could be shortened to |
How feasible is it to drop the numeric suffix too? It may or may not be possible to link a container multiple times with different internal names, so we could map:
This would make the 99% case better, and still cater to multiple-container scenarios. |
👍 |
REDIS_1_PORT_6379_TCP_ADDR instead of FIGTEST_REDIS_1_PORT_6379_TCP_ADDR. Ref #37
If the logic for figuring out the link name happens at runtime, how do we know how to write our launch commands to make use of the env variables? |
I was just wondering the same thing. How is it possible to configure apps running within containers when environment names aren't (entirely) predictable? I'm trying to use Fig with an app that depends on a naming scheme like |
+100 for creating an alias without the numeric suffix. As @harto mentioned; existing applications/Dockerfiles expect linked containers to be exposed without the prefix (i.e. The number suffix (IMO) doesn't add much value; I just want to connect to the linked 'db' container; for this, I don't need to know which instance I am linked to? The only problem could occur if a linked container is upscaled; e.g. If two instances of a redis container are created. Not sure if this will work anyway with linked containers? |
👍 for removing the numeric suffix. We're building a PaaS and would like to offer support for fig.yml files but it seems odd to add the suffix at all in the container name. We don't want the users to have to change their code at all either so I'm hesitant to implement a solution where I mimic the suffix on our end. |
I agree. Was trying fig, but need to rebuild images just for this numeric prefix :'( |
People are just using hostnames now, right? Docker writes entries to /etc/hosts. This makes things easier. db:
image: my_name/db
web:
image: my_name/web
volumes:
- ./:/app
links:
- db:db
ports:
- "8080:8080" In the "web" container you can just assume you can connect to the hostname "db", without using environment variables. |
Don't you still need to derive the port from the environment?
|
Why would it vary? I always try to use 'standard' ports. The only part that varies is the IP. |
It's a good tip. I didn't realise Docker wrote a hosts file.
|
Hmm I didn't realize that either. Is this standard practice now? |
Using a hostname is standard practice AFAIK, yes :) Where I work, we tend to link containers with logical names, then pass an environment variable specifying that name, which doesn't preclude running the same container in production, where the other container is not linked, but is actually running on a completely different server.
|
I see. That makes complete sense. Thanks :) I guess this becomes a non issue for me then. |
@d11wtq can you point me to any docs for this behavior? |
Also could anyone give an example for how to use this with |
@saulshanabrook https://docs.docker.com/userguide/dockerlinks/ Assuming your db host has been linked as 'db',
|
Huh. That is pretty cool. Thanks. Do you know why they don't use that technique in the "Getting started with Django" docs? |
Do the getting start with Django docs use Docker? I'm not a Django user, sorry. |
Oh no I meant the fig ones, http://orchardup.github.io/fig/django.html |
I think they are probably out of date. The hostname was introduced to Docker after the environment variable approach. |
Correct - I don't believe links created I'd be interested in making that the default (along with a suffix-free link alias), if there aren't any hidden drawbacks. |
👍 |
That's a 👍 for the idea. There probably are drawbacks, but I haven't thought about it too much. |
I've run into my fair share of problems with this, so my $0.02 and workarounds:
|
hi, coming #342, I wanted to comment here, that the environment variables are defined by docker, and that's not something |
Closes #37. Signed-off-by: Aanand Prasad <[email protected]>
@stonefury this issue is not about the |
So in our environment we've run into a problem of multiple environment variables being created for the same thing. We'll have something like REDIS_PORT_6379_TCP_ADDR:6379 Is this a fig problem or docker? It makes a lot of mess for the environment variables because we'll have like 20 environment variables that will all be replicated three times. |
This is a Fig problem and it's for the sake of backwards compatibility. On Thu, Aug 14, 2014 at 10:56 AM, Connor Humphries <[email protected]
|
Thanks @aanand is a next release scheduled already? |
REDIS_1_PORT_6379_TCP_ADDR instead of FIGTEST_REDIS_1_PORT_6379_TCP_ADDR. Ref docker#37 Signed-off-by: Yuval Kohavi <[email protected]>
Closes docker#37. Signed-off-by: Aanand Prasad <[email protected]> Signed-off-by: Yuval Kohavi <[email protected]>
Close stdin after data has been copied
FIGTEST_REDIS_1_PORT_6379_TCP_ADDR
This is ridiculous.
The text was updated successfully, but these errors were encountered: