Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass arguments to docker build, but NOT via cli

Is it possible to pass docker build build-arg arguments not as CLI parameters, but as environment variables for example?

I need to pass some sensitive information inside the build container, and if I do it using --build-arg it is getting exposed to other users of the system.

Is there a way to pass it in some other fashion?
(I know that I can do it using docker-compose, but I don’t have docker-compose in that case)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is only possible via --build-args.

Sensitive information should not be passed as build args anyway, because as described in the docs

It is not recommended to use build-time variables for passing secrets like github keys, user credentials etc. Build-time variable
values are visible to any user of the image with the docker history
command.

Use --secret instead to pass sensitive info (reference).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading