compose icon indicating copy to clipboard operation
compose copied to clipboard

Environment variables need to be better

Open bfirsh opened this issue 12 years ago • 31 comments

FIGTEST_REDIS_1_PORT_6379_TCP_ADDR

This is ridiculous.

bfirsh avatar Jan 20 '14 17:01 bfirsh

Oh no I meant the fig ones, http://orchardup.github.io/fig/django.html

saulshanabrook avatar Jul 17 '14 00:07 saulshanabrook

I think they are probably out of date. The hostname was introduced to Docker after the environment variable approach.

d11wtq avatar Jul 17 '14 00:07 d11wtq

Correct - I don't believe links created /etc/hosts entries back when Fig was launched.

I'd be interested in making that the default (along with a suffix-free link alias), if there aren't any hidden drawbacks.

aanand avatar Jul 17 '14 00:07 aanand

:+1:

bfirsh avatar Jul 17 '14 17:07 bfirsh

That's a :+1: for the idea. There probably are drawbacks, but I haven't thought about it too much.

bfirsh avatar Jul 17 '14 17:07 bfirsh

I've run into my fair share of problems with this, so my $0.02 and workarounds:

  • Using the hostnames written into /etc/hosts works great except that with Fig they contain underscores for the prefix, which is technically not an allowed character in URLs, and ends up breaking URL parsers.

  • To re-write the environment variables from what Fig provides to what my application expects in the real world, I have been using a custom ENTRYPOINT that does something like this:

    #!/usr/bin/env bash
    export REDIS_URLS="$REDIS_1_PORT"
    exec $@
    

ryanbrainard avatar Jul 21 '14 07:07 ryanbrainard

hi, coming #342, I wanted to comment here, that the environment variables are defined by docker, and that's not something fig should try to change, it's a docker convention. what fig decides (and ultimately impacts those env vars) is the container name. the _1 seems unnecessary, web container should be named web (and then the env vars would be named as in any other docker setup)

benjamine avatar Jul 24 '14 19:07 benjamine

@stonefury this issue is not about the _1, but about using hosts instead of env vars, about getting rid the _1 I created #349

benjamine avatar Jul 30 '14 20:07 benjamine

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 REDIS_1_PORT_6379_TCP_ADDR:6379 FIGTEST_REDIS_1_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.

humphries40 avatar Aug 14 '14 17:08 humphries40

This is a Fig problem and it's for the sake of backwards compatibility. Perhaps we should phase these out over the course of a few releases. Or, we should just ship 1.0.0.

On Thu, Aug 14, 2014 at 10:56 AM, Connor Humphries <[email protected]

wrote:

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 REDIS_1_PORT_6379_TCP_ADDR:6379 FIGTEST_REDIS_1_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.

— Reply to this email directly or view it on GitHub https://github.com/docker/fig/issues/37#issuecomment-52218435.

bfirsh avatar Aug 14 '14 19:08 bfirsh

Thanks @aanand is a next release scheduled already?

thaJeztah avatar Sep 04 '14 20:09 thaJeztah