-
Notifications
You must be signed in to change notification settings - Fork 585
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
Secret-files not found in docker/build-push-action@v6, but works with docker buildx build #1326
Comments
Same as #293 (comment):
In your case: secrets: |
id=pip,src=${{ env.GITHUB_WORKSPACE }}/.config/pip/pip.conf or you can use the secret-files: |
pip=${{ env.GITHUB_WORKSPACE }}/.config/pip/pip.conf |
@crazy-max Both suggestions do not work |
Can you show full logs of your workflow or link to your repo please? |
@crazy-max I appreciate your help, but unfortunately, I can’t share the full logs or link to the repository since this is a company project. However, if you let me know which specific details you need, I can provide relevant logs or configurations while ensuring confidentiality. To clarify, I have tested both of the following approaches: secret-files: |
pip=${{ env.GITHUB_WORKSPACE }}/.config/pip/pip.conf And: secrets: |
id=pip,src=${{ env.GITHUB_WORKSPACE }}/.config/pip/pip.conf Neither of them worked. However, when I use docker buildx build manually, the secret is passed correctly, and /run/secrets/pip is available inside the container. I also noticed that $GITHUB_WORKSPACE is set automatically, but $env.GITHUB_WORKSPACE appears to be empty by default and not explicitly configured. Additionally, if you have a minimal working example that I can run as-is, I would be happy to test it on my setup to compare the results. Thanks again for your time! |
Ah I see why it doesn't work now: https://docs.docker.com/build/ci/github-actions/secrets/
And See docs https://docs.docker.com/build/ci/github-actions/secrets/ and inputs description in our README: https://github.com/docker/build-push-action/?tab=readme-ov-file#inputs So in your case you could use secret-files: |
pip=${{ env.GITHUB_WORKSPACE }}/.config/pip/pip.conf But it seems
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Configure Python
run: |
mkdir -p $GITHUB_WORKSPACE/.config/pip
echo "[global]
extra-index-url = ${{ secrets.BPUSH_1326 }}" > $GITHUB_WORKSPACE/.config/pip/pip.conf
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: ./bpush-1326
secret-files: |
pip=${{ github.workspace }}/.config/pip/pip.conf Also you could just use -
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: ./bpush-1326
secrets: |
"pip=[global]
extra-index-url = ${{ secrets.BPUSH_1326 }}" |
@crazy-max Thank you so much! That finally solved my problem. Using ${{ github.workspace }} for secret-files: and adjusting permissions within the Dockerfile did the trick. I really appreciate your help – you just saved my week! 🎉 |
Contributing guidelines
I've found a bug, and:
Description
I am using docker/build-push-action@v6 in a GitHub Actions pipeline to build a Docker image.
I need to pass a pip.conf file as a BuildKit secret to authenticate private dependencies, but --mount=type=secret does not find the file inside the container.
However, when I run the same command manually using docker buildx build, it works perfectly.
Expected behaviour
The build should safely pass the pip.conf file and allow the installation of private dependencies similar to the BuildX command.
Actual behaviour
Repository URL
No response
Workflow run URL
No response
YAML workflow
Workflow logs
BuildKit logs
Additional info
What I Have Checked
✅ The
pip.conf
file exists in the build context and is not empty.✅ Running the command manually with
docker buildx build
works perfectly:✅ BuildKit is enabled (
DOCKER_BUILDKIT=1
).✅ Debugging with
ls
confirms that the file exists before the build starts.✅ This issue only happens with
docker/build-push-action@v6
.I have further analyzed the issue and found the following insights:
Running
docker buildx build
directly → works.The secret is passed correctly,
/run/secrets/pip
is available.Using
docker/build-push-action@v5
withsecret-files:
orsecrets:
with the exact same path→ does not work.Error: Even though the file exists.
Tried different Paths for the file:
→ Same Error even though the file exists at every place
I also created a question on Stackoverflow
The text was updated successfully, but these errors were encountered: