CodexBloom - Programming Q&A Platform

GitHub Actions scenarios to build Docker image with 'permission denied' when using BuildKit

👀 Views: 985 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-02
github-actions docker buildkit YAML

I recently switched to I'm getting frustrated with I'm working on a personal project and I'm sure I'm missing something obvious here, but I'm trying to build a Docker image using GitHub Actions with BuildKit enabled, but I'm running into a 'permission denied' behavior during the image build process. My workflow configuration looks like this: ```yaml name: Build Docker Image on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Build Docker Image run: | echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin docker build --secret id=mysecret,src=secret.txt . - name: Push Docker Image run: | docker push my-image:latest ``` I have enabled BuildKit by setting the environment variable `DOCKER_BUILDKIT=1` in my repository settings, but I still encounter the following behavior: ``` behavior: failed to solve: failed to read secret 'mysecret': open /path/to/secret.txt: permission denied ``` I confirmed that `secret.txt` is included in the repository and should be accessible in the context of the build. I also checked that the file permissions are set correctly. I tried adding `run: chmod 644 secret.txt` before the build step, but it didn't resolve the scenario. Could this be related to how I have configured BuildKit, or is there another step I'm missing that could be causing this behavior? Any insights would be greatly appreciated, as I'm trying to automate my Docker image builds and this scenario is blocking my progress. For context: I'm using Yaml on Linux. My development environment is Ubuntu. Any help would be greatly appreciated! I've been using Yaml for about a year now. Any pointers in the right direction? Any pointers in the right direction?