-
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
Secure way to handle environment variables? #277
Comments
Yeah - no. 2 is basically #76, though your solution can supply defaults too. I'd really like to be able to do this. As described here, there are complications regarding how it'd interact with another feature relating to environment variables, but I think that feature's less important than this one, so I'm tempted to say let's ignore that and merge it. |
Aanand, thanks for pointing these two issues. Looks like the only problem in merging #76 is its potential for breaking #64 in a future implementation of the last one? In the way I've thought about this, it won't be a problem. Instead of evaluating every environment variable on Update: looks like there are some people willing to apply this to keys also, not only its values. |
I'm not sure what's in the API itself (it would be easy to implement client-side), but Docker's --env-file flag may be of some help here too. The idea of an env file has certainly long been a way of keeping sensitive data out of version control anyway. |
Interesting - I didn't know about This points toward a solution which is both 100% compliant with the Docker approach and wouldn't conflict with #64: 1. Support an 'environment' array where each entry can optionally specify a value. web:
build: .
environment:
- DEBUG=true
- SECRET_API_TOKEN Fig will pull the value for SECRET_API_TOKEN from the current environment. 2. As a future enhancement, allow environment variable expansion. web:
build: .
environment:
- DEBUG=true
- SECRET_API_TOKEN
- THINGS_URL=https://example.com/api/v1/things.json?apiToken=$SECRET_API_TOKEN Thoughts? |
I didn't knew about that either, but anyone knows in what version it was introduced? Docker 0.9.1 (from Ubuntu 14.04 repos) doesn't have this option. Update: it was added on version 0.10.0.
This is interesting. I've only found out about it when reading the cli reference, as this isn't mentioned on the documentation about the
The way #64 could be implemented was already figured out? The easiest workaround I've found to use variables generated by links in this way is running a shell script that reads them and set new variables, before executing the target command.
This solution looks very nice for now (until #64 is resolved). |
The I also didn't know about the |
I guess you're right, Chris, as Docker >= 1.0.0 is now tagged for production, the API is stable, etc. I don't like to handle packages without a manager like |
Oh, I just assumed Ubuntu would be up-to-date :) Yeah, 1.0 shouldn't be making any breaking changes now, though I do imagine new features will continue to be added (with appropriate version changes). I use Gentoo which tends to be about as up to date as you can get (docker seems to be updated the day after it is released). |
Fig should support: environment:
- FOO=bar
- EXAMPLE Where |
Are there any ideas on how to support host variables on osx? |
Doesn't it work? I haven't tested it, but it seems like it would be a client-side feature. |
Sorry for not being clear. On OSX docker is running in a VM. So the "host variables" would be the ones in the VM and not the ones from the current user on OSX. |
I thought only the daemon was on the VM, but the client was still on OS X, just using $DOCKER_HOST. I will have to experiment though, as I don’t run docker on OS X itself (I use a VM). On 7 Jul 2014, at 9:18 am, Stefan Foulis notifications@github.com wrote:
|
Ah, you are right. It's the docker client issuing the commands and that is actually running on OSX. So it might not be an issue at all. Sorry for the noise. |
I tested this out, but Fig (or docker-py rather) does not work out of the box to support key-only environment variables like the Docker CLI. I just sent a pull request to docker-py to fix this:
|
Actually, thinking about it, I'm not sure it should be an implicit measure taken by the client and should be something that fig would do. The reason for that is that the client can't really assume it's running on the command line (or even on the same machine as the end-user). It's safer that it require explicit inputs and outputs. So in that case, fig would need to recognize env vars without an assignment, then look them up from the environment itself and replace them accordingly. Let's see what the docker-py guys do anyway :) |
@ryanbrainard I'm pretty sure |
@d11wtq I agree that the |
How can I handle environment variables in a secure way, e.g. not explicitly writing them on
Dockerfile
orfig.yml
? This is needed for settings like Django's SECRET_KEY.I've tried some approaches, without success:
.gitignore
"_env:VARIABLE_NAME[:DEFAULT]"
, like docker-registryfig up
, to be passed to the docker client as-e
I'll try to implement the second one (guess it needs just a little modification here), but if someone is already doing this in another way, I would really like to know.
Regards,
Tiago.
The text was updated successfully, but these errors were encountered: