Skip to content
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

Allow passing secret enviroment variables to build #1703

Closed
rittneje opened this issue Sep 25, 2020 · 12 comments
Closed

Allow passing secret enviroment variables to build #1703

rittneje opened this issue Sep 25, 2020 · 12 comments

Comments

@rittneje
Copy link
Contributor

Currently, you can pass file-based secrets to docker build via --secret and RUN --mount. However, often our secrets are actually environment variables, such as a username and password. We can work around this limitation by writing the environment variable to some file, passing that file a secret, mounting it in the RUN step, and then reading the file into an environment variable. However, this is very awkward.

I think it would be better if these environment variables could be passed in directly as secrets. Something like this:

docker build --secret-env USERNAME --secret-env PASSWORD
RUN --env=USERNAME --env=PASSWORD ...

(These flag names are just for demonstration purposes. I am open to whatever names you think would make the most sense.)

@tonistiigi
Copy link
Member

The first part is implemented in master #1534 . for second use RUN MY_SECRET=$(cat /run/secrets/foo) cmd

@rittneje
Copy link
Contributor Author

Did not know about #1534, thanks! But I still think it'd be nice not to have to use cat in the Dockerfile.

@chirangaalwis
Copy link

chirangaalwis commented Oct 9, 2020

@tonistiigi @rittneje is this part of the BuildKit feature of Docker CLI? If so, it isn't mentioned in the documentation.

@rittneje
Copy link
Contributor Author

As I understand it, this feature is only present in master and has yet to be officially released.

@chirangaalwis
Copy link

@tonistiigi @rittneje appreciate if so, appreciate if you could confirm when this feature will be available with Docker.

@tonistiigi
Copy link
Member

was vendored into docker cli in docker/cli#2656

@hasinthaindrajee
Copy link

hasinthaindrajee commented Nov 5, 2020

@tonistiigi : Would you be able to let us know whether you have any idea of merging this to 19.03 branch so that it will be available in 19.03.x release ?

@tonistiigi
Copy link
Member

@hasinthaindrajee probably will not happen as the next release is already in beta.

@danilobuerger
Copy link

It would be really nice if RUN --mount could be simplified too... right now its:

RUN --mount=type=secret,id=SECRET SECRET=$(cat /run/secrets/SECRET) ...

@lindhe
Copy link

lindhe commented Apr 5, 2022

Perhaps I was looking in the wrong place, but is env entirely undocumented??

@kevcube
Copy link

kevcube commented Apr 26, 2022

@lindhe I'd say you are looking in the wrong place, I went to the Dockerfile reference which says if you're using BuildKit, then look at the BuildKit reference, but it's not documented there either.

So as far as I can tell.. it's entirely undocumented. @tonistiigi can you confirm?

@tonistiigi
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants