Passing in duplicate buildargs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Please pardon this "support" type request, but reading the docs, and the source code (namely https://github.com/docker/docker-py/blob/master/docker/api/build.py) I didn't see a way to do this.
For the "buildargs" dict passed to image.build, how do you support build arguments which can be given more than once? For example, the --secret parameter documented here: https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information
You can specify --secret more than once on the command line, with different values each time. Code:
echo 'WARMACHINEROX' > mysecret.txt
echo 'WARMACHINEROX2' > mysecret2.txt
export DOCKER_BUILDKIT=1
cat <<EOF > Dockerfile
FROM alpine
# shows secret from default secret location:
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
RUN --mount=type=secret,id=mysecret2 cat /run/secrets/mysecret2
EOF
docker build --no-cache --progress=plain --secret id=mysecret,src=mysecret.txt --secret id=mysecret2,src=mysecret2.txt .
produces:
<snip>
#9 [2/5] RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
#9 0.500 WARMACHINEROX
#9 DONE 0.6s
#10 [3/5] RUN --mount=type=secret,id=mysecret2 cat /run/secrets/mysecret2
#10 0.560 WARMACHINEROX2
#10 DONE 0.6s
<snip>
How might I go about passing in both arguments?
From reading the code, it does not appear this will work:
buildargs[secret] = ['id=mysecret,src=mysecret.txt', 'id=mysecret2,src=mysecret2.txt']
Ideas? Suggestions?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docker/api/build.py and the image.build buildargs handling, then compare it with Docker's documented repeated --secret options and the Docker Engine API representation. Done means the supported input for multiple build arguments is established and verified against the example behavior; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100