Skip to content

Instantly share code, notes, and snippets.

@huksley
Created December 1, 2022 07:43
Show Gist options
  • Save huksley/919ba2a48c3d3931770d80f99adf8cfc to your computer and use it in GitHub Desktop.
Save huksley/919ba2a48c3d3931770d80f99adf8cfc to your computer and use it in GitHub Desktop.
Pass environment variables in the shell to subcommand by some prefix, e.g. DOCKER_
#!/bin/bash
# Pass all DOCKER_ARG_NAME=VALUE as --build-arg NAME=VALUE
docker buildx build . --tag test1 \
(for N in "${!DOCKER_ARG_@}"; do echo -n "--build-arg ${N/DOCKER_ARG_/}=${!N} "; done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment