I'm building a Docker image using multiple build args, and was wondering if it was possible to pass them to docker build
as a file, in the same way --env-file
can be pased to docker run
. The env file will be parsed by docker run
automatically and the variables made available in the container.
Is it possible to specify a file of build arguments in the same way?
There's no such an option, at least for now. But if you have too many build args and want to save it in a file, you can archive it as follows:
Save the following shell to buildargs.sh
, make it executable and put it in your PATH
:
#!/bin/bash
awk '{ sub ("\\\\$", " "); printf " --build-arg %s", $0 } END { print "" }' $@
Build your image with argfile
like:
docker build $(buildargs.sh argfile) -t your_image .