Github Action for Windows platform "Windows does not support privileged mode"

Viewed 27

I have a Windows, .NET Framework 4.8 microservice which I am attempting to dockerize and deploy through Github Actions. (.NET Framework 4.8 hence windows containers is required due to a hard dependency, so Linux is not an option.)

The action is failing on the "buildx" step due to "Windows does not support privileged mode" error. However I can build it manually on my local machine.

The base image is:

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8

The relevant section from the workflow YML script is:

  docker-build_my_awesome_microservice:
    name: Builds my_awesome_microservice docker
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and Push my_awesome_microservice
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: windows/amd64
          push: true
          tags: ghcr.io/my_awesome_company/my_awesome_microservice:development-latest

And the build fails on Github with:

Run docker/build-push-action@v2
  with:
    context: .
    push: true
    tags: ghcr.io/my_awesome_company/my_awesome_microservice:development-latest
    load: false
    no-cache: false
    pull: false
    github-token: ***
  env:
    HELM_TIMEOUT: 600s
    HELM_NAMESPACE: apps
    HELM_CHART_VERSION: 0.1.0
    HELM_CHARTS_PAT_TOKEN: ***
Docker info
"C:\Program Files\Docker\docker.exe" buildx build --iidfile C:/Users/RUNNER~1/AppData/Local/Temp/docker-build-push-O5M3gs/iidfile --tag ghcr.io/my_awesome_company/my_awesome_microservice:development-latest --metadata-file C:/Users/RUNNER~1/AppData/Local/Temp/docker-build-push-O5M3gs/metadata-file --push .
#1 [internal] booting buildkit
#1 pulling image moby/buildkit:buildx-stable-1
#1 pulling image moby/buildkit:buildx-stable-1 0.2s done
#1 creating container buildx_buildkit_builder-bca52bcd-f172-4d75-b242-502ec5f0071c0 done
#1 ERROR: Error response from daemon: Windows does not support privileged mode
------
 > [internal] booting buildkit:
------
ERROR: Error response from daemon: Windows does not support privileged mode
Error: buildx failed with: ERROR: Error response from daemon: Windows does not support privileged mode

I have searched high and low and failed to find a solution in docs etc.

How can I get this Github Action to successfully build and push a Windows based docker image?

1 Answers

With help from the comments above, I simply changed the docker build step to use a Windows-compatible action (namely mr-smithers-excellent/docker-build-push@v5) and this worked:

 docker-build_my_awesome_microservice:
    name: Build my_awesome_microservice docker
    runs-on: windows-latest
    needs: test_my_awesome_microservice
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Build and Push my_awesome_microservice
        uses: mr-smithers-excellent/docker-build-push@v5
        with:
          image: my_awesome_microservice
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
          platform: windows/amd64
          tags: development-latest
Related