Search code examples
boot2dockerfig

Making host-resolved environment variables work with fig on boot2docker


According to the fig YML reference, I should be able to declare an environment variable with only a key to resolve this to the corresponding variable on the host. That doesn't work for me in boot2docker.

Here's my fig.yml:

test:
    image: ubuntu
    command: env
    environment:
        TESTVAR:

I'm running TESTVAR=foo fig up and I'm getting the following output:

test_1 | TESTVAR=

I suspect this is because I'm using the fig container with the alias from fig #598 in boot2docker, which probably doesn't pass the environment variables through properly. Is there any workaround for this?


Solution

  • The value should be getting picked up from the environment where fig is run using https://docs.python.org/2/library/os.html#os.environ

    Looking at that alias, it does look like the fig command actually gets run in a container, so I think you're right.

    You could modify the alias to pass in other environment variables using

    -e TESTVAR=$(TESTVAR)