Skip to content
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

Windows: Build images with windows-host-process-containers-base-image fails with Cannot create a file when that file already exists. (0xb7): unknown #5196

Open
jkroepke opened this issue Jul 29, 2024 · 0 comments

Comments

@jkroepke
Copy link

I tried to build a https://github.com/microsoft/windows-host-process-containers-base-image/ which is considered as special.

windows-host-process-containers-base-image is a very special image, because its hand-crafted image.

I'm using Github Actions to build an images on top of windows-host-process-containers-base-image

Here are the actions I'm using:

      - name: Setup containerd
        run: |
          $version = "1.7.20"
          curl.exe -L https://github.com/containerd/containerd/releases/download/v$version/containerd-$version-windows-amd64.tar.gz -o containerd.tar.gz
          tar.exe xvf containerd.tar.gz
          .\bin\containerd.exe --register-service
          Start-Service containerd
      - name: Setup BuildKit
        run: |
          $version = "v0.15.0"
          curl.exe -L https://github.com/moby/buildkit/releases/download/$version/buildkit-$version.windows-amd64.tar.gz -o buildkit.tar.gz
          tar.exe xvf buildkit.tar.gz
          
          .\bin\buildkitd.exe --register-service
          Start-Service buildkitd
      - name: Setup Docker Buildx
        run: |
          $version = "v0.16.1"
          curl.exe -L https://github.com/docker/buildx/releases/download/$version/buildx-$version.windows-amd64.exe -o $env:ProgramData\Docker\cli-plugins\docker-buildx.exe
      - uses: docker/setup-buildx-action@v3
        with:
          driver: remote
          endpoint: npipe:////./pipe/buildkitd

While build looks fine, exporting the images causes unknown errors:

docker buildx build --push --build-arg=BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 -f Dockerfile -t ghcr.io/prometheus-community/windows-exporter:master-hostprocess .
#0 building with "builder-e1408480-a0f9-48a2-aa8d-31bc0261d2ff" instance using remote driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 490B done
#1 DONE 0.0s

#2 [internal] load metadata for mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
#2 DONE 0.1s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [internal] load build context
#4 transferring context: 115B done
#4 DONE 0.0s

#5 [1/2] FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0@sha256:b4c9637e032f667c52d1eccfa31ad8c63f1b035e8639f3f48a510536bf34032b
#5 resolve mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0@sha256:b4c9637e032f667c52d1eccfa31ad8c63f1b035e8639f3f48a510536bf34032b
#5 resolve mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0@sha256:b4c9637e032f667c52d1eccfa31ad8c63f1b035e8639f3f48a510536bf34032b 0.1s done
#5 DONE 0.1s

#6 [2/2] COPY output/amd64/windows_exporter.exe /windows_exporter.exe
#6 CACHED

#7 exporting to image
#7 exporting layers
#7 exporting layers 0.2s done
#7 ERROR: failed to commit 5am92igktp6scjpj0kc7ejaj3 to oumlt8yasx34v7sb7a31zzo9f during finalize: failed to reimport snapshot: hcsshim::ImportLayer failed in Win32: Cannot create a file when that file already exists. (0xb7): unknown
------
 > exporting to image:
------
ERROR: failed to solve: failed to commit 5am92igktp6scjpj0kc7ejaj3 to oumlt8yasx34v7sb7a31zzo9f during finalize: failed to reimport snapshot: hcsshim::ImportLayer failed in Win32: Cannot create a file when that file already exists. (0xb7): unknown

Dockerfile, mention that BASE will be overwrite by --build-arg:

ARG BASE="mcr.microsoft.com/windows/nanoserver:ltsc2022"
FROM $BASE

ENV PATH="C:\Windows\system32;C:\Windows;"
COPY output/amd64/windows_exporter.exe /windows_exporter.exe
ENTRYPOINT ["windows_exporter.exe"]

Ref: https://github.com/prometheus-community/windows_exporter/actions/runs/10078511673/job/27863581327#step:17:266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants